20 lines
451 B
Ruby
20 lines
451 B
Ruby
|
# The code to manage adl scheduling. Repeat events, is managed here
|
||
|
module Schedule
|
||
|
def schedule
|
||
|
IceCube::Schedule.new start_time, end_time: end_time do |s|
|
||
|
s.add_recurrence_rule prepare_schedule.count repeat + 1
|
||
|
end
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
def prepare_schedule
|
||
|
r = IceCube::Rule.send rule.split('_').first
|
||
|
if rule == 'monthly_day'
|
||
|
r.day_of_week start_time.wday => [start_time.day / 7 + 1]
|
||
|
else
|
||
|
r
|
||
|
end
|
||
|
end
|
||
|
end
|