2016-09-17 17:19:41 +02:00
|
|
|
# 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'
|
2016-11-21 16:00:40 +01:00
|
|
|
r.day_of_week start_time.wday => [(start_time.day - 1) / 7 + 1]
|
2016-09-17 17:19:41 +02:00
|
|
|
else
|
|
|
|
r
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|