Class: Fabulator::Grammar::Expr::Text

Inherits:
Object
  • Object
show all
Defined in:
lib/fabulator/grammar/expr/text.rb

Instance Method Summary collapse

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

#nameObject



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_regexObject



7
8
9
# File 'lib/fabulator/grammar/expr/text.rb', line 7

def to_regex
  Regexp.escape(@text)
end