Class: BSON::Regexp::Raw

Inherits:
Object
  • Object
show all
Defined in:
lib/bson/regexp.rb

Overview

Represents the raw values for the regular expression.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pattern, options) ⇒ Raw

Initialize the new raw regular expression.

Examples:

Initialize the raw regexp.

Raw.new(pattern, options)

Parameters:

  • pattern (String)

    The regular expression pattern.

  • options (Integer)

    The options.

Since:

  • 3.0.0



144
145
146
147
# File 'lib/bson/regexp.rb', line 144

def initialize(pattern, options)
  @pattern = pattern
  @options = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *arguments) ⇒ Object (private)

Since:

  • 3.0.0



161
162
163
164
# File 'lib/bson/regexp.rb', line 161

def method_missing(method, *arguments)
  return super unless respond_to?(method)
  compile.send(method, *arguments)
end

Instance Attribute Details

#optionsInteger (readonly)

Returns options The options.

Returns:

  • (Integer)

    options The options.

Since:

  • 3.0.0



121
122
123
# File 'lib/bson/regexp.rb', line 121

def options
  @options
end

#patternString (readonly)

Returns pattern The regex pattern.

Returns:

  • (String)

    pattern The regex pattern.

Since:

  • 3.0.0



118
119
120
# File 'lib/bson/regexp.rb', line 118

def pattern
  @pattern
end

Instance Method Details

#compile::Regexp

Compile the Regular expression into the native type.

Examples:

Compile the regular expression.

raw.compile

Returns:

  • (::Regexp)

    The compiled regular expression.

Since:

  • 3.0.0



131
132
133
# File 'lib/bson/regexp.rb', line 131

def compile
  @compiled ||= ::Regexp.new(pattern, options)
end

#respond_to?(method, include_private = false) ⇒ Boolean

Allow automatic delegation of methods to the Regexp object returned by compile.

Parameters:

  • method (String)

    The name of a method.

Returns:

Since:

  • 3.1.0



155
156
157
# File 'lib/bson/regexp.rb', line 155

def respond_to?(method, include_private = false)
  compile.respond_to?(method, include_private = false) || super
end