Class: Peggy::Positive
- 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
Instance Method Summary collapse
-
#match(parser, index) ⇒ Object
Matches the child once.
-
#to_s ⇒ Object
Convert element to String.
Methods included from OneChild
Methods inherited from Element
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_s ⇒ Object
Convert element to String.
203 204 205 |
# File 'lib/parse/builder.rb', line 203 def to_s "&#{wrap}" end |