class Regexp

Public Instance Methods

__match?(needle, thread_state = nil) click to toggle source
# File lib/cannonbol/cannonbol.rb, line 576
def __match?(needle, thread_state = nil)
  if RUBY_ENGINE == 'opal'
    options = ""
    options += "m" if `#{self}.multiline`
    options += "g" if `#{self}.global`
    options += "i" if needle.ignore_case or `#{self}.ignoreCase`
  else
    options = self.options | (needle.ignore_case ? Regexp::IGNORECASE : 0)
  end
  @cannonbol_regex ||= Regexp.new("^#{self.source}", options )
  if thread_state
    needle.pull(thread_state)
  elsif m = @cannonbol_regex.match(needle.remaining_string)
    [needle.push(m[0].length)]
  end
end