Module: Stagger
- Defined in:
- lib/stagger.rb,
lib/stagger/version.rb
Constant Summary collapse
- SECONDS_IN_DAY =
86_400
- VERSION =
"0.2.0"
Class Method Summary collapse
-
.distribute(items, number_of_days, delay: 0) ⇒ Array
Evenly distributes items acros business days.
Class Method Details
.distribute(items, number_of_days, delay: 0) ⇒ Array
Evenly distributes items acros business days
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/stagger.rb', line 11 def distribute(items, number_of_days, delay: 0) return [] if Array(items).empty? || number_of_days.to_i < 1 time = get_starting_time(delay) period_in_seconds = get_period_in_seconds(items.size, number_of_days, time) items.reduce [] do |arr, item| if business_day?(time) arr << [item, time] time = time + period_in_seconds arr else time = time + SECONDS_IN_DAY redo end end end |