Class: MTK::Patterns::Sequence
- Defined in:
- lib/mtk/patterns/sequence.rb
Overview
A finite list of elements, which can be enumerated one at a time.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Pattern
#cycle_count, #element_count, #elements, #max_cycles, #max_elements, #min_elements, #options
Instance Method Summary collapse
-
#advance ⇒ Object
protected
Update internal state (index, etc) and set @current to the next element.
Methods inherited from Pattern
#empty?, from_a, #initialize, #max_cycles_exceeded?, #max_elements_exceeded?, #min_elements_unmet?, #next, #rewind, #rewind_or_cycle
Methods included from Groups::Collection
#==, #[], #clone, #concat, #each, #empty?, #enumerable_map, #first, #last, #map, #partition, #permute, #repeat, #reverse, #rotate, #size, #to_a
Constructor Details
This class inherits a constructor from MTK::Patterns::Pattern
Instance Method Details
#advance ⇒ Object (protected)
Update internal state (index, etc) and set @current to the next element.
11 12 13 14 15 |
# File 'lib/mtk/patterns/sequence.rb', line 11 def advance @index += 1 raise StopIteration if @index >= @elements.length @current = @elements[@index] end |