class Montrose::Rule::NthDayMatcher
Public Class Methods
new(wday, period_day)
click to toggle source
# File lib/montrose/rule/nth_day_matcher.rb, line 12 def initialize(wday, period_day) @wday = wday @period_day = period_day end
Public Instance Methods
matches?(nth_occ)
click to toggle source
# File lib/montrose/rule/nth_day_matcher.rb, line 17 def matches?(nth_occ) nth_occ == current_occ || (nth_occ < 0 && (total_occ + nth_occ + 1) == current_occ) end
Private Instance Methods
current_occ()
click to toggle source
# File lib/montrose/rule/nth_day_matcher.rb, line 23 def current_occ @current_occ ||= (nth_day - first_occ) / 7 + 1 end
first_occ()
click to toggle source
# File lib/montrose/rule/nth_day_matcher.rb, line 31 def first_occ @first_occ ||= ((7 - first_wday) + @wday) % 7 + 1 end
total_occ()
click to toggle source
# File lib/montrose/rule/nth_day_matcher.rb, line 27 def total_occ @total_occ ||= ((total_days - first_occ + 1) / 7.0).ceil end