Class: BSON::Boolean

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

Overview

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

See Also:

Since:

  • 2.0.0

Constant Summary collapse

BSON_TYPE =

A boolean is type 0x08 in the BSON spec.

Since:

  • 2.0.0

::String.new(8.chr, encoding: BINARY).freeze

Class Method Summary collapse

Class Method Details

.from_bson(buffer, **options) ⇒ TrueClass, FalseClass

Deserialize a boolean from BSON.

Parameters:

  • buffer (ByteBuffer)

    The byte buffer.

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :mode (nil | :bson)

    Decoding mode to use.

Returns:

See Also:

Since:

  • 2.0.0



43
44
45
46
47
48
49
50
51
52
# File 'lib/bson/boolean.rb', line 43

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