class Moped::BSON::Timestamp

A time representation in BSON.

Public Instance Methods

__bson_dump__(io, key) click to toggle source

Serialize the time to the stream.

@example Serialize the time.

time.__bson_dump__("", "created_at")

@param [ String ] io The raw bytes. @param [ String ] key The field name.

@since 1.0.0

# File lib/moped/bson/timestamp.rb, line 16
def __bson_dump__(io, key)
  io << [17, key, increment, seconds].pack('cZ*l2')
end
__bson_load__(io) click to toggle source

Deserialize the timestamp to an object.

@example Deserialize the time.

Moped::BSON::Timestamp.__bson_load__(string)

@param [ String ] io The raw bytes.

@return [ Timestamp ] The time.

@since 1.0.0

# File lib/moped/bson/timestamp.rb, line 32
def __bson_load__(io)
  new(*io.read(8).unpack('l2').reverse)
end