def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?)
      if bson_int32?
        buffer.put_int32(self)
      elsif bson_int64?
        buffer.put_int64(self)
      else
        out_of_range!
      end
    end
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?)
      if bson_int32?
        buffer.put_int32(self)
      elsif bson_int64?
        buffer.put_int64(self)
      else
        out_of_range!
      end
    end
Get the integer as encoded BSON.

 @example Get the integer as encoded BSON.
   1024.to_bson

 @return [ BSON::ByteBuffer ] The buffer with the encoded object.

 @see http://bsonspec.org/#/specification

 @since 2.0.0