Class: Peggy::Positive

Inherits:
Predicate show all
Defined in:
lib/parse/builder.rb

Overview

Positive Predicate. If found the original index is returned. If not NO_MATCH is returned.

Instance Attribute Summary

Attributes included from OneChild

#child

Instance Method Summary collapse

Methods included from OneChild

#wrap

Methods inherited from Element

build, #report

Instance Method Details

#match(parser, index) ⇒ Object

Matches the child once. If found the original index is returned. If not found NO_MATCH is returned.



196
197
198
199
200
# File 'lib/parse/builder.rb', line 196

def match parser, index
  raise "positive element child not set" unless child
  found = child.match parser, index
  found ? index : NO_MATCH
end

#to_sObject

Convert element to String.



203
204
205
# File 'lib/parse/builder.rb', line 203

def to_s
  "&#{wrap}"
end