class BSON::MaxKey

Represents a $maxKey type, which compares less than any other value in the specification.

@see bsonspec.org/#/specification

@since 2.0.0

Constants

BSON_TYPE

A $maxKey is type 0x7F in the BSON spec.

@since 2.0.0

GREATER

Constant for always evaluating greater in a comparison.

@since 2.0.0

Public Instance Methods

<=>(other) click to toggle source

When comparing a max key with any other object, the max key will always be greater.

@example Compare with another object.

max_key <=> 1000

@param [ Object ] other The object to compare against.

@return [ Integer ] Always 1.

@since 2.0.0

# File lib/bson/max_key.rb, line 50
def <=>(other)
  GREATER
end
as_extended_json(**options) click to toggle source

Converts this object to a representation directly serializable to Extended JSON (github.com/mongodb/specifications/blob/master/source/extended-json.rst).

@option opts [ nil | :relaxed | :legacy ] :mode Serialization mode

(default is canonical extended JSON)

@return [ Hash ] The extended json representation.

# File lib/bson/max_key.rb, line 74
def as_extended_json(**options)
  { "$maxKey" => 1 }
end
as_json(*args) click to toggle source

Get the max key as JSON hash data.

@example Get the max key as a JSON hash.

max_key.as_json

@return [ Hash ] The max key as a JSON hash.

@since 2.0.0 @deprecated Use as_extended_json instead.

# File lib/bson/max_key.rb, line 63
def as_json(*args)
  as_extended_json
end