Class: Moped::BSON::Timestamp

Inherits:
Struct
  • Object
show all
Defined in:
lib/moped/bson/timestamp.rb

Overview

A time representation in BSON.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#incrementObject

Returns the value of attribute increment

Returns:

  • (Object)

    the current value of increment



5
6
7
# File 'lib/moped/bson/timestamp.rb', line 5

def increment
  @increment
end

#secondsObject

Returns the value of attribute seconds

Returns:

  • (Object)

    the current value of seconds



5
6
7
# File 'lib/moped/bson/timestamp.rb', line 5

def seconds
  @seconds
end

Class Method Details

.__bson_load__(io) ⇒ Timestamp

Deserialize the timestamp to an object.

Examples:

Deserialize the time.

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

Parameters:

  • io (String)

    The raw bytes.

Returns:

Since:

  • 1.0.0



32
33
34
# File 'lib/moped/bson/timestamp.rb', line 32

def __bson_load__(io)
  new(*io.read(8).unpack('l2').reverse)
end

Instance Method Details

#__bson_dump__(io, key) ⇒ Object

Serialize the time to the stream.

Examples:

Serialize the time.

time.__bson_dump__("", "created_at")

Parameters:

  • io (String)

    The raw bytes.

  • key (String)

    The field name.

Since:

  • 1.0.0



16
17
18
# File 'lib/moped/bson/timestamp.rb', line 16

def __bson_dump__(io, key)
  io << [17, key, increment, seconds].pack('cZ*l2')
end