Class: HolidaysRules::Rules::FixWeekDay

Inherits:
RuleBase
  • Object
show all
Defined in:
lib/holidays_rules/rules.rb

Instance Method Summary collapse

Methods inherited from RuleBase

#==, #eql?, #hash

Constructor Details

#initialize(week, wday, month) ⇒ FixWeekDay

Returns a new instance of FixWeekDay.



124
125
126
127
128
# File 'lib/holidays_rules/rules.rb', line 124

def initialize(week, wday, month)
  @week = week
  @wday = wday
  @month = month
end

Instance Method Details

#holiday?(date) ⇒ Boolean

Returns:

  • (Boolean)


130
131
132
133
# File 'lib/holidays_rules/rules.rb', line 130

def holiday?(date)
  week = (date.day - 1) / 7 + 1
  @wday == date.wday && @month == date.month && @week == week
end