class Cannonbol::Span

Public Instance Methods

__match?(needle, match_length = nil, thread_state = nil) click to toggle source
# File lib/cannonbol/cannonbol.rb, line 436
def __match?(needle, match_length = nil, thread_state = nil)
  unless match_length
    the_chars, match_length = chars(needle), 0
    while needle.remaining_string.length > match_length and the_chars.include? needle.remaining_string[match_length..match_length]
      match_length += 1
    end
  end
  needle.pull(thread_state)
  if match_length > 0
    thread_state = needle.push(match_length)
    match_length -= 1
    [match_length, thread_state]
  end
end