class Reservation::Schedule::Daily
a utility class to represent an interval starting on a day
Attributes
interval[RW]
nth_of_month[RW]
wday[RW]
Public Class Methods
new(wday, nth_of_month, interval)
click to toggle source
# File lib/reservation/daily.rb, line 11 def initialize wday, nth_of_month, interval @wday = wday @nth_of_month = nth_of_month @interval = interval end
Public Instance Methods
generate(date, list)
click to toggle source
# File lib/reservation/daily.rb, line 21 def generate date, list return list unless good_day?(date) list << interval.generate(date) list end
good_day?(date)
click to toggle source
# File lib/reservation/daily.rb, line 27 def good_day? date (date.wday == self.wday) && ((self.nth_of_month == :all) || date.nth_day_of_month?(self.nth_of_month)) end
matches?(event)
click to toggle source
# File lib/reservation/daily.rb, line 17 def matches? event good_day?(event.start.to_date) && interval.matches?(event) end
to_s()
click to toggle source
# File lib/reservation/daily.rb, line 31 def to_s "#{MAP_DAY[wday]} => #{interval}" end