Method: BSON::Integer#to_bson

Defined in:
lib/bson/integer.rb

#to_bson(buffer = ByteBuffer.new) ⇒ BSON::ByteBuffer

Get the integer as encoded BSON.

Examples:

Get the integer as encoded BSON.

1024.to_bson

Returns:

See Also:

Since:

  • 2.0.0



108
109
110
111
112
113
114
115
116
# File 'lib/bson/integer.rb', line 108

def to_bson(buffer = ByteBuffer.new)
  if bson_int32?
    buffer.put_int32(self)
  elsif bson_int64?
    buffer.put_int64(self)
  else
    out_of_range!
  end
end