class ActivePeriod::Collection::StandardPeriod

Private Instance Methods

enumerator() click to toggle source
# File lib/active_period/collection/standard_period.rb, line 8
def enumerator
  Enumerator.new do |yielder|
    current = klass.new(period.begin)
    while current.calculated_end <= period.calculated_end || period.include?(current)
      yielder << current if period.include?(current)
      current = current.next
    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/standard_period.rb, line 20
def reverse_enumerator
  Enumerator.new do |yielder|
    current = klass.new(period.calculated_end)
    while current.begin <= period.begin || period.include?(current)
      yielder << current if period.include?(current)
      current = current.prev
    end
    # At the end (if there is one) the Collection will be return
    self
  end
end