Class: OperatingHours::HolidayCollection
- Inherits:
-
Object
- Object
- OperatingHours::HolidayCollection
- Defined in:
- lib/operating_hours/holiday_collection.rb
Instance Method Summary collapse
- #days_in_date_range(first_date, second_date) ⇒ Object
- #include?(date) ⇒ Boolean
-
#initialize(collection:, schedule:) ⇒ HolidayCollection
constructor
A new instance of HolidayCollection.
- #seconds_in_date_range(first_date, second_date) ⇒ Object
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
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 |