class Biz::Periods::Linear

Attributes

periods[R]
selector[R]
sequences[R]
shifts[R]

Public Class Methods

new(periods, shifts, selector) click to toggle source
Calls superclass method
# File lib/biz/periods/linear.rb, line 7
def initialize(periods, shifts, selector)
  @periods   = periods.to_enum
  @shifts    = shifts.to_enum
  @selector  = selector
  @sequences = [@periods, @shifts]

  super(linear_periods)
end

Private Instance Methods

linear_periods() click to toggle source
# File lib/biz/periods/linear.rb, line 23
def linear_periods
  Enumerator.new do |yielder|
    loop do
      periods.next and next if periods.peek.date == shifts.peek.date

      yielder << begin
        sequences
          .public_send(selector) { |sequence| sequence.peek.date }
          .next
      end
    end

    loop do yielder << periods.next end
  end
end