Class: HolidayCo::Year

Inherits:
Object
  • Object
show all
Defined in:
lib/holiday_co/models/year.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(year) ⇒ Year

Returns a new instance of Year.



10
11
12
# File 'lib/holiday_co/models/year.rb', line 10

def initialize(year)
  @year = year.to_s
end

Instance Attribute Details

#yearObject (readonly)

Returns the value of attribute year.



8
9
10
# File 'lib/holiday_co/models/year.rb', line 8

def year
  @year
end

Instance Method Details

#holiday_datesObject



24
25
26
# File 'lib/holiday_co/models/year.rb', line 24

def holiday_dates
  holidays.map { |h| h[:date] }
end

#holiday_namesObject



20
21
22
# File 'lib/holiday_co/models/year.rb', line 20

def holiday_names
  holidays.map { |h| h[:name] }
end

#holidaysObject



14
15
16
17
18
# File 'lib/holiday_co/models/year.rb', line 14

def holidays
  raise YearDataNotAvailableError unless year_data_available?

  HolidayCalculator.for(year)
end