Class: Nextday::Holidays

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Singleton
Defined in:
lib/nextday/holidays.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHolidays

Returns a new instance of Holidays.



9
10
11
# File 'lib/nextday/holidays.rb', line 9

def initialize
  @holidays = PUBLIC_HOLIDAYS
end

Class Method Details

.datesArray

Returning all the dates holidays occur

Returns:

  • (Array)

    of holidays as [Date] objects



21
22
23
# File 'lib/nextday/holidays.rb', line 21

def self.dates
  instance.map(&:date)
end

.find(date) ⇒ Holiday

Find the first holiday for the supplied date

Parameters:

  • format (Date)

    the format type, ‘:text` or `:html`

Returns:

  • (Holiday)

    the first matching holiday for the supplied date



29
30
31
# File 'lib/nextday/holidays.rb', line 29

def self.find(date)
  instance.find{ |holiday| holiday.date == date }
end

Instance Method Details

#each(&block) ⇒ Object



13
14
15
# File 'lib/nextday/holidays.rb', line 13

def each(&block)
  @holidays.each{|holiday| block.call(holiday)}
end