11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/holidays/finder/rules/year_range.rb', line 11
def call(target_year, year_range_defs)
validate!(target_year, year_range_defs)
operator = year_range_defs.keys.first
rule_value = year_range_defs[operator]
case operator
when UNTIL
matched = target_year <= rule_value
when FROM
matched = target_year >= rule_value
when LIMITED
matched = rule_value.include?(target_year)
when BETWEEN
matched = rule_value.cover?(target_year)
else
matched = false
end
matched
end
|