class Laser::Cutter::Notching::InfiniteIterator

Alternating iterator

Attributes

array[RW]
calls[RW]
next_index[RW]

Public Class Methods

new(array) click to toggle source
# File lib/laser-cutter/notching/path_generator.rb, line 19
def initialize(array)
  self.array = array
  self.calls = 0
  self.next_index = 0
end

Public Instance Methods

next() { |item, calls| ... } click to toggle source
# File lib/laser-cutter/notching/path_generator.rb, line 25
def next
  item = self.array[next_index].clone
  self.next_index += 1
  self.next_index %= array.size
  self.calls += 1
  item = yield item, self.calls if block_given?
  item
end