Class: MTK::Patterns::Cycle
- Defined in:
- lib/mtk/patterns/cycle.rb
Overview
An endless enumerator that outputs an element one at a time from a list of elements, looping back to the beginning when elements run out. This is the same as a Sequence but by default has unlimited @max_cycles
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
-
#initialize(elements, options = {}) ⇒ Cycle
constructor
A new instance of Cycle.
Methods inherited from Sequence
Methods inherited from Pattern
#advance, #empty?, from_a, #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
#initialize(elements, options = {}) ⇒ Cycle
Returns a new instance of Cycle.
9 10 11 12 13 |
# File 'lib/mtk/patterns/cycle.rb', line 9 def initialize(elements, ={}) super # Base Pattern & Sequence default to 1 max_cycle, this defaults to nil which is unlimited cycles @max_cycles = [:max_cycles] end |