Class: HolidayCo::Year
- Inherits:
-
Object
- Object
- HolidayCo::Year
- Defined in:
- lib/holiday_co/models/year.rb
Instance Attribute Summary collapse
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
- #holiday_dates ⇒ Object
- #holiday_names ⇒ Object
- #holidays ⇒ Object
-
#initialize(year) ⇒ Year
constructor
A new instance of Year.
Constructor Details
#initialize(year) ⇒ Year
Returns a new instance of Year.
15 16 17 |
# File 'lib/holiday_co/models/year.rb', line 15 def initialize(year) @year = year.to_s end |
Instance Attribute Details
#year ⇒ Object (readonly)
Returns the value of attribute year.
13 14 15 |
# File 'lib/holiday_co/models/year.rb', line 13 def year @year end |
Instance Method Details
#holiday_dates ⇒ Object
32 33 34 |
# File 'lib/holiday_co/models/year.rb', line 32 def holiday_dates holidays.map { |h| h[:date] } end |
#holiday_names ⇒ Object
28 29 30 |
# File 'lib/holiday_co/models/year.rb', line 28 def holiday_names holidays.map { |h| h[:name] } end |
#holidays ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/holiday_co/models/year.rb', line 19 def holidays raise YearDataNotAvailableError unless year_data_available? YAML .load_file(File.("../../../../data/years/#{year}.yml", __FILE__)) .fetch("holidays", []) .map { |h| h.transform_keys(&:to_sym) } end |