Class: Fabulator::Grammar::Expr::Text
- Inherits:
-
Object
- Object
- Fabulator::Grammar::Expr::Text
- Defined in:
- lib/fabulator/grammar/expr/text.rb
Instance Method Summary collapse
-
#initialize(t) ⇒ Text
constructor
A new instance of Text.
- #name ⇒ Object
- #parse(cursor) ⇒ Object
- #to_regex ⇒ Object
Constructor Details
#initialize(t) ⇒ Text
Returns a new instance of Text.
3 4 5 |
# File 'lib/fabulator/grammar/expr/text.rb', line 3 def initialize(t) @text = t end |
Instance Method Details
#name ⇒ Object
11 12 13 |
# File 'lib/fabulator/grammar/expr/text.rb', line 11 def name nil end |
#parse(cursor) ⇒ Object
15 16 17 |
# File 'lib/fabulator/grammar/expr/text.rb', line 15 def parse(cursor) cursor.match_token(Regexp.quote(@text)) end |
#to_regex ⇒ Object
7 8 9 |
# File 'lib/fabulator/grammar/expr/text.rb', line 7 def to_regex Regexp.escape(@text) end |