class Peggy::Literal
Matcher of a literal string or regular expression.
Attributes
value[R]
Value to match.
Public Class Methods
new(value=nil)
click to toggle source
Init the value.
# File lib/parse/builder.rb, line 290 def initialize value=nil @value = value end
Public Instance Methods
match(parser, index)
click to toggle source
Match the literal value. If it matches the end index is returned. If no, NO_MATCH is returned.
# File lib/parse/builder.rb, line 303 def match parser, index report parser.literal?(value, index) end
to_s()
click to toggle source
Convert element to String.
# File lib/parse/builder.rb, line 308 def to_s value.inspect end
value=(literal)
click to toggle source
Set the value to match.
# File lib/parse/builder.rb, line 295 def value= literal # Make sure regular expressions check at the beginnig of the string literal = correct_regexp literal if literal.is_a? Regexp @value = literal end