Class: NationalHolidays::Region
- Inherits:
-
Object
- Object
- NationalHolidays::Region
- Defined in:
- lib/national_holidays/region.rb
Class Attribute Summary collapse
-
.cache ⇒ Object
readonly
Returns the value of attribute cache.
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Class Method Summary collapse
Instance Method Summary collapse
- #all_holidays ⇒ Object
- #holidays_after(date) ⇒ Object
- #holidays_before(date) ⇒ Object
- #holidays_between(start_date, end_date) ⇒ Object
- #holidays_on_or_after(date) ⇒ Object
- #holidays_on_or_before(date) ⇒ Object
-
#initialize(code) ⇒ Region
constructor
A new instance of Region.
- #name ⇒ Object
Constructor Details
#initialize(code) ⇒ Region
Returns a new instance of Region.
17 18 19 |
# File 'lib/national_holidays/region.rb', line 17 def initialize(code) @code = code.to_sym end |
Class Attribute Details
.cache ⇒ Object (readonly)
Returns the value of attribute cache.
69 70 71 |
# File 'lib/national_holidays/region.rb', line 69 def cache @cache end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
9 10 11 |
# File 'lib/national_holidays/region.rb', line 9 def code @code end |
Class Method Details
.all ⇒ Object
11 12 13 14 15 |
# File 'lib/national_holidays/region.rb', line 11 def self.all Dir.glob("#{NationalHolidays.config_directory}/*/*.yml").map do |region_filename| new(File.basename(region_filename).sub(/\.yml/, '')) end.sort_by(&:code) end |
Instance Method Details
#all_holidays ⇒ Object
25 26 27 |
# File 'lib/national_holidays/region.rb', line 25 def all_holidays holidays end |
#holidays_after(date) ⇒ Object
41 42 43 |
# File 'lib/national_holidays/region.rb', line 41 def holidays_after(date) holidays(date.next_day, nil) end |
#holidays_before(date) ⇒ Object
33 34 35 |
# File 'lib/national_holidays/region.rb', line 33 def holidays_before(date) holidays(nil, date.prev_day) end |
#holidays_between(start_date, end_date) ⇒ Object
45 46 47 |
# File 'lib/national_holidays/region.rb', line 45 def holidays_between(start_date, end_date) holidays(start_date, end_date) end |
#holidays_on_or_after(date) ⇒ Object
37 38 39 |
# File 'lib/national_holidays/region.rb', line 37 def holidays_on_or_after(date) holidays(date, nil) end |
#holidays_on_or_before(date) ⇒ Object
29 30 31 |
# File 'lib/national_holidays/region.rb', line 29 def holidays_on_or_before(date) holidays(nil, date) end |
#name ⇒ Object
21 22 23 |
# File 'lib/national_holidays/region.rb', line 21 def name config.fetch('name') end |