Injects behaviour for encoding and decoding regular expression values to and from raw bytes as specified by the BSON spec.
@see bsonspec.org/#/specification
@since 2.0.0
Get the regular expression as encoded BSON.
@example Get the regular expression as encoded BSON.
%r{\d+}.to_bson
@note From the BSON spec: The first cstring is the regex pattern,
the second is the regex options string. Options are identified by characters, which must be stored in alphabetical order. Valid options are 'i' for case insensitive matching, 'm' for multiline matching, 'x' for verbose mode, 'l' to make \w, \W, etc. locale dependent, 's' for dotall mode ('.' matches everything), and 'u' to make \w, \W, etc. match unicode.
@return [ String ] The encoded string.
@see bsonspec.org/#/specification
@since 2.0.0
# File lib/bson/regexp.rb, line 62 def to_bson(encoded = ''.force_encoding(BINARY)) source.to_bson_cstring(encoded) bson_options.to_bson_cstring(encoded) end
Generated with the Darkfish Rdoc Generator 2.