Class: MTK::Patterns::Sequence

Inherits:
Pattern
  • Object
show all
Defined in:
lib/mtk/patterns/sequence.rb

Overview

A finite list of elements, which can be enumerated one at a time.

Direct Known Subclasses

Cycle

Instance Attribute Summary

Attributes inherited from Pattern

#cycle_count, #element_count, #elements, #max_cycles, #max_elements, #min_elements, #options

Instance Method Summary collapse

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

#advanceObject (protected)

Update internal state (index, etc) and set @current to the next element.

Raises:

  • (StopIteration)


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