Class: Holidays::Finder::Context::DatesDriverBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/holidays/finder/context/dates_driver_builder.rb

Instance Method Summary collapse

Instance Method Details

#build(dates_driver = {}, date) ⇒ Object

FIXME Why is the date_driver set to optional as the first param? That’s just plain wrong…

Raises:

  • (ArgumentError)


20
21
22
23
24
25
26
# File 'lib/holidays/finder/context/dates_driver_builder.rb', line 20

def build(dates_driver = {}, date)
  raise ArgumentError unless dates_driver
  raise ArgumentError unless date
  dates_driver[date.year] = [] unless dates_driver[date.year]
  dates_driver[date.year] << date.month
  dates_driver = add_border_months(date, dates_driver)
end

#call(start_date, end_date) ⇒ Object



11
12
13
14
15
16
# File 'lib/holidays/finder/context/dates_driver_builder.rb', line 11

def call(start_date, end_date)
  dates_driver = {}

  (start_date..end_date).map{|current_date|build(dates_driver, current_date)}
  clean(dates_driver)
end