module MongoOplogBackup::Ext::Timestamp::ClassMethods

Public Instance Methods

from_json(data) click to toggle source

Accepts {'t' => seconds, 'i' => increment} or {'$timestamp' => {'t' => seconds, 'i' => increment}}

# File lib/mongo_oplog_backup/ext/timestamp.rb, line 25
def from_json(data)
  data = data['$timestamp'] if data['$timestamp']
  self.new(data['t'], data['i'])
end
from_string(string) click to toggle source

Accepts: <seconds>

# File lib/mongo_oplog_backup/ext/timestamp.rb, line 31
def from_string(string)
  match = /(\d+)(?::(\d+))?/.match(string)
  return nil unless match
  s1 = match[1].to_i
  i1 = match[2].to_i
  self.new(s1,i1)
end