class KPeg::LiteralString

Attributes

string[R]

Public Class Methods

new(str) click to toggle source
Calls superclass method KPeg::Operator::new
# File lib/kpeg/grammar.rb, line 73
def initialize(str)
  super()
  @string = str
  @reg = Regexp.new Regexp.quote(str)
end

Public Instance Methods

==(obj) click to toggle source
Calls superclass method
# File lib/kpeg/grammar.rb, line 89
def ==(obj)
  case obj
  when LiteralString
    @string == obj.string
  else
    super
  end
end
inspect() click to toggle source
# File lib/kpeg/grammar.rb, line 98
def inspect
  inspect_type 'str', @string.inspect
end
match(x) click to toggle source
# File lib/kpeg/grammar.rb, line 81
def match(x)
  if str = x.scan(@reg)
    MatchString.new(self, str)
  else
    x.fail(self)
  end
end