class BSON::Timestamp

A class for representing BSON Timestamps. The Timestamp type is used by MongoDB internally; thus, it should be used by application developers for diagnostic purposes only.

Attributes

increment[R]
seconds[R]

Public Class Methods

new(seconds, increment) click to toggle source

Create a new BSON Timestamp.

@param [Integer] seconds The number of seconds @param increment

# File lib/bson/types/timestamp.rb, line 29
def initialize(seconds, increment)
  @seconds   = seconds
  @increment = increment
end

Public Instance Methods

==(other) click to toggle source
# File lib/bson/types/timestamp.rb, line 38
def ==(other)
  self.seconds == other.seconds &&
    self.increment == other.increment
end
[](index) click to toggle source

This is for backward-compatibility. Timestamps in the Ruby driver used to deserialize as arrays. So we provide an equivalent interface.

@deprecated

# File lib/bson/types/timestamp.rb, line 48
def [](index)
  warn "Timestamps are no longer deserialized as arrays. If you're working " +
    "with BSON Timestamp objects, see the BSON::Timestamp class. This usage will " +
    "be deprecated in Ruby Driver v2.0."
  if index == 0
    self.increment
  elsif index == 1
    self.seconds
  else
    nil
  end
end
each() { |self| ... } click to toggle source

This method exists only for backward-compatibility.

@deprecated

# File lib/bson/types/timestamp.rb, line 64
def each
  i = 0
  while i < 2
    yield self[i]
    i += 1
  end
end
to_s() click to toggle source
# File lib/bson/types/timestamp.rb, line 34
def to_s
  "seconds: #{seconds}, increment: #{increment}"
end