Class: Peggy::Literal

Inherits:
Element show all
Defined in:
lib/builder.rb,
lib/Copy of builder.rb

Overview

Matcher of a literal string or regular expression.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Element

build, #report

Constructor Details

#initialize(value = nil) ⇒ Literal

Init the value.



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

def initialize value=nil
  @value = value
end

Instance Attribute Details

#valueObject

Value to match.



211
212
213
# File 'lib/builder.rb', line 211

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.



227
228
229
# File 'lib/builder.rb', line 227

def match parser, index
  report parser.literal?(value, index)
end

#to_sObject



231
232
233
# File 'lib/builder.rb', line 231

def to_s
  value.inspect
end