class Arugula

Constants

VERSION

Attributes

captures[R]

Public Class Methods

new(pattern) click to toggle source
# File lib/arugula.rb, line 10
def initialize(pattern)
  @root, @captures = Parser.new(pattern).parse!
end

Public Instance Methods

==(other) click to toggle source
# File lib/arugula.rb, line 44
def ==(other)
  return false unless other.is_a?(Arugula) || other.is_a?(Regexp)
  inspect == other.inspect
end
hash() click to toggle source
# File lib/arugula.rb, line 40
def hash
  to_s.hash
end
inspect()
Alias for: to_s
match(str, index = 0) click to toggle source
# File lib/arugula.rb, line 19
def match(str, index = 0)
  match_data = MatchData.new(self, str)
  loop do
    match_data.reset_captures!
    match, end_index = @root.match(str, index, match_data)
    if match
      match_data.start_index = index
      match_data.end_index = end_index
      return match_data.freeze
    end
    index += 1
    return if index > str.size
  end
end
match?(str, index = 0) click to toggle source
# File lib/arugula.rb, line 14
def match?(str, index = 0)
  match_data = match(str, index)
  match_data && match_data.start_index
end
to_s() click to toggle source
# File lib/arugula.rb, line 34
def to_s
  "/#{@root}/"
end
Also aliased as: inspect