Class: PEG::Literal
- Inherits:
-
Rule
- Object
- ValueObject
- Rule
- PEG::Literal
- Defined in:
- lib/peg.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Rule
Instance Method Summary collapse
- #_inspect ⇒ Object
-
#initialize(literal) ⇒ Literal
constructor
A new instance of Literal.
- #match(text) ⇒ Object
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
#_inspect ⇒ Object
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 |