Class: Boost::Regexp

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-boost-regex/ruby-parts.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.enable_monkey_patch!Object



5
6
7
8
9
10
# File 'lib/ruby-boost-regex/ruby-parts.rb', line 5

def enable_monkey_patch!
  ::Regexp.__send__(:define_method, :boost!) do |*args|
    flags = args.any? ? args.first : Boost::Regexp::NORMAL
    Boost::Regexp.new(self.source, flags)
  end
end

Instance Method Details

#casefold?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/ruby-boost-regex/ruby-parts.rb', line 13

def casefold?
  (self.options & IGNORECASE) > 0
end

#inspectObject



17
18
19
20
21
22
23
# File 'lib/ruby-boost-regex/ruby-parts.rb', line 17

def inspect
  base = "/#{source}/"
  base << "m" if options & Boost::Regexp::DOTS_MATCH_NEWLINES > 0
  base << "i" if options & Boost::Regexp::IGNORECASE > 0
  base << "x" if options & Boost::Regexp::IGNORE_WHITESPACE > 0
  base
end