Class: BSON::Int32
- Inherits:
-
Object
- Object
- BSON::Int32
- Defined in:
- lib/bson/int32.rb
Overview
Represents a $maxKey type, which compares less than any other value in the specification.
Constant Summary collapse
- BSON_TYPE =
A boolean is type 0x08 in the BSON spec.
16.chr.force_encoding(BINARY).freeze
- BYTES_LENGTH =
The number of bytes constant.
4
- PACK =
Constant for the int 32 pack directive.
"l<".freeze
Class Method Summary collapse
-
.from_bson(buffer) ⇒ Integer
Deserialize an Integer from BSON.
Instance Method Summary collapse
-
#initialize(integer) ⇒ Int32
constructor
Instantiate a BSON Int32.
-
#to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) ⇒ BSON::ByteBuffer
Append the integer as encoded BSON to a ByteBuffer.
-
#to_bson_key(validating_keys = Config.validating_keys?) ⇒ String
Convert the integer to a BSON string key.
Constructor Details
#initialize(integer) ⇒ Int32
Instantiate a BSON Int32.
60 61 62 63 |
# File 'lib/bson/int32.rb', line 60 def initialize(integer) out_of_range! unless integer.bson_int32? @integer = integer.freeze end |
Class Method Details
.from_bson(buffer) ⇒ Integer
Deserialize an Integer from BSON.
49 50 51 |
# File 'lib/bson/int32.rb', line 49 def self.from_bson(buffer) buffer.get_int32 end |
Instance Method Details
#to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) ⇒ BSON::ByteBuffer
Append the integer as encoded BSON to a ByteBuffer.
75 76 77 |
# File 'lib/bson/int32.rb', line 75 def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_int32(@integer) end |
#to_bson_key(validating_keys = Config.validating_keys?) ⇒ String
Convert the integer to a BSON string key.
89 90 91 |
# File 'lib/bson/int32.rb', line 89 def to_bson_key(validating_keys = Config.validating_keys?) @integer.to_bson_key(validating_keys) end |