class Cannonbol::Arbno

Public Instance Methods

__match?(needle, pattern = nil, s = [[]]) click to toggle source
# File lib/cannonbol/cannonbol.rb, line 489
def __match?(needle, pattern = nil, s = [[]])
  return if s.length == 0
  if pattern
    existing_captures = needle.captures.dup
    s[-1] = pattern._match?(needle, *(s.last))
    s = s[-1] ? s + [[]] : s[0..-2]
    needle.captures = needle.captures.merge(existing_captures)
  else
    if @block
      pattern = @block.call
    elsif @name
      pattern = needle.captures[@name] || ""
    else
      pattern = @pattern
    end
  end
  [pattern, s]
end