Class: OperatingHours::HolidayCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/operating_hours/holiday_collection.rb

Instance Method Summary collapse

Constructor Details

#initialize(collection:, schedule:) ⇒ HolidayCollection

Returns a new instance of HolidayCollection.



4
5
6
7
# File 'lib/operating_hours/holiday_collection.rb', line 4

def initialize(collection:, schedule:)
  @schedule = schedule
  @dates = calculate_holidays_time(collection)
end

Instance Method Details

#days_in_date_range(first_date, second_date) ⇒ Object



9
10
11
# File 'lib/operating_hours/holiday_collection.rb', line 9

def days_in_date_range(first_date, second_date)
  holidays_before(second_date + 1) - holidays_before(first_date)
end

#include?(date) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/operating_hours/holiday_collection.rb', line 17

def include?(date)
  get(date)[:holiday?]
end

#seconds_in_date_range(first_date, second_date) ⇒ Object



13
14
15
# File 'lib/operating_hours/holiday_collection.rb', line 13

def seconds_in_date_range(first_date, second_date)
  holiday_seconds_before(second_date + 1) - holiday_seconds_before(first_date)
end