Class: PEG::Literal

Inherits:
Rule show all
Defined in:
lib/peg.rb

Direct Known Subclasses

Regex

Instance Attribute Summary

Attributes inherited from Rule

#children

Instance Method Summary collapse

Methods inherited from Rule

#inspect, #name, #parse, #result

Methods inherited from ValueObject

#==

Constructor Details

#initialize(literal) ⇒ Literal

Returns a new instance of Literal.



56
57
58
59
# File 'lib/peg.rb', line 56

def initialize(literal)
  @literal = literal
  @children = []
end

Instance Method Details

#_inspectObject



65
66
67
# File 'lib/peg.rb', line 65

def _inspect
  @literal.inspect
end

#match(text) ⇒ Object



61
62
63
# File 'lib/peg.rb', line 61

def match(text)
  text.start_with?(@literal) ? result(@literal) : nil
end