class Holidays::UseCase::Context::Between
Attributes
custom_methods_repo[R]
day_of_month_calculator[R]
holidays_by_month_repo[R]
proc_result_cache_repo[R]
Public Class Methods
new(holidays_by_month_repo, day_of_month_calculator, custom_methods_repo, proc_result_cache_repo)
click to toggle source
# 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
Public Instance Methods
call(start_date, end_date, dates_driver, regions, observed, informal)
click to toggle source
# 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
Private Instance Methods
validate!(start_date, end_date, dates_driver, regions)
click to toggle source
# File lib/holidays/use_case/context/between.rb, line 30 def validate!(start_date, end_date, dates_driver, regions) raise ArgumentError unless start_date raise ArgumentError unless end_date raise ArgumentError if dates_driver.nil? || dates_driver.empty? dates_driver.each do |year, months| raise ArgumentError if months.nil? || months.empty? end raise ArgumentError if regions.nil? || regions.empty? end