Class: Montrose::Rule::NthDayMatcher

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/montrose/rule/nth_day_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(wday, period_day) ⇒ NthDayMatcher

Returns a new instance of NthDayMatcher.



12
13
14
15
# File 'lib/montrose/rule/nth_day_matcher.rb', line 12

def initialize(wday, period_day)
  @wday = wday
  @period_day = period_day
end

Instance Method Details

#matches?(nth_occ) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# 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