Module: SwedishHolidays
- Extended by:
- Enumerable
- Defined in:
- lib/swedish_holidays.rb,
lib/swedish_holidays/utils.rb,
lib/swedish_holidays/holiday.rb
Defined Under Namespace
Modules: Utils
Classes: Error, Holiday
Constant Summary
collapse
- DATA_DIR =
File.expand_path('../../../data', __FILE__).freeze
Class Method Summary
collapse
Class Method Details
.[](date) ⇒ Object
9
10
11
12
13
|
# File 'lib/swedish_holidays.rb', line 9
def self.[](date)
return Holiday.find Utils.to_date(date) unless date.is_a? Range
range = Utils.to_date_range(date)
each(start: range.first).take_while { |h| range.include? h.date }
end
|
.each(start: nil) ⇒ Object
19
20
21
22
23
|
# File 'lib/swedish_holidays.rb', line 19
def self.each(start: nil)
enumerator = Utils.enumerator(start)
return enumerator.lazy unless block_given?
enumerator.each { |holiday| yield holiday }
end
|
.holiday?(date = nil) ⇒ Boolean
15
16
17
|
# File 'lib/swedish_holidays.rb', line 15
def self.holiday?(date = nil)
Holiday.holiday? Utils.to_date(date)
end
|