Class: Peggy::Literal
Overview
Matcher of a literal string or regular expression.
Instance Attribute Summary collapse
-
#value ⇒ Object
Value to match.
Instance Method Summary collapse
-
#initialize(value = nil) ⇒ Literal
constructor
Init the value.
-
#match(parser, index) ⇒ Object
Match the literal value.
-
#to_s ⇒ Object
Convert element to String.
Methods inherited from Element
Constructor Details
#initialize(value = nil) ⇒ Literal
Init the value.
290 291 292 |
# File 'lib/parse/builder.rb', line 290 def initialize value=nil @value = value end |
Instance Attribute Details
#value ⇒ Object
Value to match.
287 288 289 |
# File 'lib/parse/builder.rb', line 287 def value @value end |
Instance Method Details
#match(parser, index) ⇒ Object
Match the literal value. If it matches the end index is returned. If no, NO_MATCH is returned.
303 304 305 |
# File 'lib/parse/builder.rb', line 303 def match parser, index report parser.literal?(value, index) end |
#to_s ⇒ Object
Convert element to String.
308 309 310 |
# File 'lib/parse/builder.rb', line 308 def to_s value.inspect end |