class Arugula::LiteralPart

Attributes

literal[RW]

Public Class Methods

new(literal) click to toggle source
# File lib/arugula/parts.rb, line 19
def initialize(literal)
  @literal = literal
end

Public Instance Methods

match(str, index, _match_data) click to toggle source
# File lib/arugula/parts.rb, line 27
def match(str, index, _match_data)
  length = literal.size
  matches = str[index, length] == literal
  [matches, index + (matches ? length : 0)]
end
to_s() click to toggle source
# File lib/arugula/parts.rb, line 23
def to_s
  literal.gsub('\\', '\\\\').gsub(/[.]/) { |m| "\\#{m}" }
end