Class: Holidays::Finder::Context::Between
- Inherits:
-
Object
- Object
- Holidays::Finder::Context::Between
- Defined in:
- lib/holidays/finder/context/between.rb
Instance Method Summary collapse
- #call(start_date, end_date, options) ⇒ Object
-
#initialize(definition_search, dates_driver_builder, options_parser) ⇒ Between
constructor
A new instance of Between.
Constructor Details
#initialize(definition_search, dates_driver_builder, options_parser) ⇒ Between
Returns a new instance of Between.
5 6 7 8 9 |
# File 'lib/holidays/finder/context/between.rb', line 5 def initialize(definition_search, dates_driver_builder, ) @definition_search = definition_search @dates_driver_builder = dates_driver_builder @options_parser = end |
Instance Method Details
#call(start_date, end_date, options) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/holidays/finder/context/between.rb', line 11 def call(start_date, end_date, ) validate!(start_date, end_date) regions, observed, informal = @options_parser.call() dates_driver = @dates_driver_builder.call(start_date, end_date) #FIXME Why are we calling the options_parser to convert the observed/informal # symbols to bool and then...converting them back? O_o opts = (observed, informal) @definition_search .call(dates_driver, regions, opts) .select { |holiday| holiday[:date].between?(start_date, end_date) } .sort_by { |a| a[:date] } end |