Skip to content

Commit 821dd49

Browse files
committed
Improve naming and fix rubocop offenses
1 parent 2a663ab commit 821dd49

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

interval_value_randomizer.rb

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
1+
# input: daily total and a distribution percentage
2+
# output values per interval
13
class IntervalValueRandomizer
2-
def initialize(sum, value)
3-
@sum = sum # rename
4-
@value = value # rename
4+
def initialize(daily_total, distribution_factor)
5+
@daily_total = daily_total
6+
@distribution_factor = distribution_factor # rename
57
end
68

79
def calls
8-
(@value * avg_per_interval * random_de_or_increase).floor
10+
(@distribution_factor * average_value * random_modifier).floor
911
end
1012

1113
def handled_calls
1214
0
1315
end
1416

1517
def aht
16-
return 0 if calls == 0
17-
(random_de_or_increase * avg_per_interval * random_de_or_increase + 100).floor
18+
return 0 if calls.zero?
19+
20+
(random_modifier * average_value * random_modifier + 100).floor
1821
end
1922

20-
def avg_per_interval
21-
@sum / 96
23+
private
24+
25+
def average_value
26+
@daily_total / 96
2227
end
2328

24-
def random_de_or_increase
29+
def random_modifier
2530
rand(0.96..1.1)
2631
end
27-
end
32+
end

0 commit comments

Comments
 (0)