class ActivePeriod::Collection::HolidayPeriod

Attributes

options[R]

@!attribute [r] options

@return [Array] The array of options for Holidays.on

Public Class Methods

new(klass, period, *args) click to toggle source
Calls superclass method ActivePeriod::Collection::new
# File lib/active_period/collection/holiday_period.rb, line 10
def initialize(klass, period, *args)
  super(klass, period)
  @options = args
end

Private Instance Methods

enumerator() click to toggle source
# File lib/active_period/collection/holiday_period.rb, line 17
def enumerator
  Enumerator.new do |yielder|
    days = period.try(:days) || [period]
    days.each do |day|
      Holidays.on(day.begin.to_date, *options).each do |hash|
        yielder << ActivePeriod::Holiday.new(**hash, options: @options)
      end
    end
    # At the end (if there is one) the Collection will be return
    self
  end
end
reverse_enumerator() click to toggle source
# File lib/active_period/collection/holiday_period.rb, line 30
def reverse_enumerator
  Enumerator.new do |yielder|
    days = period.try(:days) || [period]
    days.reverse_each do |day|
      Holidays.on(day.begin.to_date, *options).each do |hash|
        yielder << ActivePeriod::Holiday.new(**hash, options: @options)
      end
    end
    # At the end (if there is one) the Collection will be return
    self
  end
end