Class: Holidays::UseCase::Context::Between

Inherits:
Object
  • Object
show all
Includes:
ContextCommon
Defined in:
lib/holidays/use_case/context/between.rb

Instance Method Summary collapse

Methods included from ContextCommon

#call_proc, #in_region?, #make_date_array

Constructor Details

#initialize(holidays_by_month_repo, day_of_month_calculator, custom_methods_repo, proc_result_cache_repo) ⇒ Between

Returns a new instance of Between.



7
8
9
10
11
12
# File 'lib/holidays/use_case/context/between.rb', line 7

def initialize(holidays_by_month_repo, day_of_month_calculator, custom_methods_repo, proc_result_cache_repo)
  @holidays_by_month_repo = holidays_by_month_repo
  @day_of_month_calculator = day_of_month_calculator
  @custom_methods_repo = custom_methods_repo
  @proc_result_cache_repo = proc_result_cache_repo
end

Instance Method Details

#call(start_date, end_date, dates_driver, regions, observed, informal) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/holidays/use_case/context/between.rb', line 14

def call(start_date, end_date, dates_driver, regions, observed, informal)
  validate!(start_date, end_date, dates_driver, regions)

  holidays = []
  holidays = make_date_array(dates_driver, regions, observed, informal)
  holidays = holidays.select{|holiday|holiday[:date].between?(start_date, end_date)}
  holidays.sort{|a, b| a[:date] <=> b[:date] }
end