class Peggy::Sequence
An element that matches a sequence of elements. All must match for the sequence to match.
Public Instance Methods
[](index)
click to toggle source
Reference
a child by index.
# File lib/parse/builder.rb, line 65 def [] index @list[index] end
add(element)
click to toggle source
Add a child element.
# File lib/parse/builder.rb, line 56 def add element @list = [] unless @list @list << element end
Also aliased as: <<
each(&blk)
click to toggle source
Child iterator.
# File lib/parse/builder.rb, line 70 def each &blk @list.each &blk end
match(parser, index)
click to toggle source
Match each child in sequence. If any fail this returns NO_MATCH. If all succeed this returns the end index of the last.
# File lib/parse/builder.rb, line 76 def match parser, index raise "no children added to sequence" unless @list each do |element| index = element.match parser, index return NO_MATCH unless index end report index end
to_s()
click to toggle source
Convert element to String.
# File lib/parse/builder.rb, line 86 def to_s @list.map{|el| el.to_s}.join ' ' end