Class: Peggy::Negative

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

Overview

Negative Predicate. If not found the original index is returned. If found 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 not found the original index is returned. If found NO_MATCH is returned.



214
215
216
217
218
# File 'lib/parse/builder.rb', line 214

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

#to_sObject

Convert element to String.



221
222
223
# File 'lib/parse/builder.rb', line 221

def to_s
  "!#{wrap}"
end