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



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

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



136
137
138
139
# File 'lib/bson/regexp.rb', line 136

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



96
97
98
# File 'lib/bson/regexp.rb', line 96

def options
  @options
end

#patternString (readonly)

Returns pattern The regex pattern.

Returns:

  • (String)

    pattern The regex pattern.

Since:

  • 3.0.0



93
94
95
# File 'lib/bson/regexp.rb', line 93

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



106
107
108
# File 'lib/bson/regexp.rb', line 106

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

#respond_to?(method) ⇒ 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



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

def respond_to?(method)
  compile.respond_to?(method) || super
end