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


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

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

Instance Method Details

#matches?(nth_occ) ⇒ Boolean

Returns:

  • (Boolean)

16
17
18
# File 'lib/montrose/rule/nth_day_matcher.rb', line 16

def matches?(nth_occ)
  nth_occ == current_occ || (nth_occ < 0 && (total_occ + nth_occ + 1) == current_occ)
end