Class: Laser::Cutter::Notching::InfiniteIterator
- Inherits:
-
Struct
- Object
- Struct
- Laser::Cutter::Notching::InfiniteIterator
- Defined in:
- lib/laser-cutter/notching/path_generator.rb
Overview
Alternating iterator
Instance Attribute Summary collapse
-
#array ⇒ Object
Returns the value of attribute array.
-
#calls ⇒ Object
Returns the value of attribute calls.
-
#next_index ⇒ Object
Returns the value of attribute next_index.
Instance Method Summary collapse
-
#initialize(array) ⇒ InfiniteIterator
constructor
A new instance of InfiniteIterator.
- #next ⇒ Object
Constructor Details
#initialize(array) ⇒ InfiniteIterator
Returns a new instance of InfiniteIterator.
19 20 21 22 23 |
# File 'lib/laser-cutter/notching/path_generator.rb', line 19 def initialize(array) self.array = array self.calls = 0 self.next_index = 0 end |
Instance Attribute Details
#array ⇒ Object
Returns the value of attribute array
16 17 18 |
# File 'lib/laser-cutter/notching/path_generator.rb', line 16 def array @array end |
#calls ⇒ Object
Returns the value of attribute calls.
17 18 19 |
# File 'lib/laser-cutter/notching/path_generator.rb', line 17 def calls @calls end |
#next_index ⇒ Object
Returns the value of attribute next_index.
17 18 19 |
# File 'lib/laser-cutter/notching/path_generator.rb', line 17 def next_index @next_index end |
Instance Method Details
#next ⇒ Object
25 26 27 28 29 30 31 32 |
# 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 |