Class: Packrat::StringLiteral
- Inherits:
-
RegexpLiteral
- Object
- GrammarElement
- RegexpLiteral
- Packrat::StringLiteral
- Defined in:
- lib/packrat/grammar.rb
Overview
A StringLiteral works like a RegexpLiteral. The only reason we use a special class for it is so that we can inspect it in a more natural way (as a string instead of a Regexp).
Instance Attribute Summary collapse
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Attributes inherited from GrammarElement
Instance Method Summary collapse
-
#initialize(str) ⇒ StringLiteral
constructor
A new instance of StringLiteral.
- #inspect ⇒ Object
Methods inherited from RegexpLiteral
Methods inherited from GrammarElement
Constructor Details
#initialize(str) ⇒ StringLiteral
Returns a new instance of StringLiteral.
61 62 63 64 |
# File 'lib/packrat/grammar.rb', line 61 def initialize(str) super(Regexp.new(Regexp.escape(str))) @string = str end |
Instance Attribute Details
#string ⇒ Object (readonly)
Returns the value of attribute string.
60 61 62 |
# File 'lib/packrat/grammar.rb', line 60 def string @string end |
Instance Method Details
#inspect ⇒ Object
65 |
# File 'lib/packrat/grammar.rb', line 65 def inspect; @string.inspect; end |