Module: MongoOplogBackup::Ext::Timestamp::ClassMethods
- Defined in:
- lib/mongo_oplog_backup/ext/timestamp.rb
Instance Method Summary collapse
-
#from_json(data) ⇒ Object
Accepts => seconds, ‘i’ => increment or => {‘t’ => seconds, ‘i’ => increment}.
-
#from_string(string) ⇒ Object
Accepts: <seconds>.
Instance Method Details
#from_json(data) ⇒ Object
Accepts => seconds, ‘i’ => increment or => {‘t’ => seconds, ‘i’ => increment}
25 26 27 28 |
# 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) ⇒ Object
Accepts: <seconds>
31 32 33 34 35 36 37 |
# 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 |