Class: TigerBeetle::Converters::Time
- Defined in:
- lib/tigerbeetle/converters/time.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
Class Method Details
.native_type ⇒ Object
7 8 9 |
# File 'lib/tigerbeetle/converters/time.rb', line 7 def self.native_type FFI::Type::UINT64 end |
Instance Method Details
#from_native(ptr) ⇒ Object
11 12 13 |
# File 'lib/tigerbeetle/converters/time.rb', line 11 def from_native(ptr) ::Time.at(ptr.read(FFI::Type::UINT64) / 1e9) end |
#to_native(ptr, value) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/tigerbeetle/converters/time.rb', line 15 def to_native(ptr, value) int = (value.to_f * 1e9).to_i validate_uint!(:timestamp, 64, int) ptr.write(FFI::Type::UINT64, int) end |