class BSON::Boolean

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

@see bsonspec.org/#/specification

@since 2.0.0

Constants

BSON_TYPE

A boolean is type 0x08 in the BSON spec.

@since 2.0.0

Public Class Methods

from_bson(buffer, **options) click to toggle source

Deserialize a boolean from BSON.

@param [ ByteBuffer ] buffer The byte buffer.

@option options [ nil | :bson ] :mode Decoding mode to use.

@return [ TrueClass, FalseClass ] The decoded boolean.

@see bsonspec.org/#/specification

@since 2.0.0

# File lib/bson/boolean.rb, line 42
def self.from_bson(buffer, **options)
  case v = buffer.get_byte
  when TrueClass::TRUE_BYTE
    true
  when FalseClass::FALSE_BYTE
    false
  else
    raise Error::BSONDecodeError, "Invalid boolean byte value: #{v}"
  end
end