Class: TigerBeetle::Converters::AccountBalance

Inherits:
Base
  • Object
show all
Defined in:
lib/tigerbeetle/converters/account_balance.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

from_native, to_native

Class Method Details

.native_typeObject



10
11
12
# File 'lib/tigerbeetle/converters/account_balance.rb', line 10

def self.native_type
  TBClient::AccountBalance
end

Instance Method Details

#from_native(ptr) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tigerbeetle/converters/account_balance.rb', line 14

def from_native(ptr)
  c_value = TBClient::AccountBalance.new(ptr)

  TigerBeetle::AccountBalance.new(
    debits_pending: Converters::UInt128.from_native(c_value[:debits_pending].to_ptr),
    debits_posted: Converters::UInt128.from_native(c_value[:debits_posted].to_ptr),
    credits_pending: Converters::UInt128.from_native(c_value[:credits_pending].to_ptr),
    credits_posted: Converters::UInt128.from_native(c_value[:credits_posted].to_ptr),
    timestamp: Converters::Time.from_native(ptr + c_value.offset_of(:timestamp))
  )
end

#to_native(ptr, value) ⇒ Object



26
27
28
# File 'lib/tigerbeetle/converters/account_balance.rb', line 26

def to_native(ptr, value)
  raise 'Unexpected conversion of AccountBalance to native type'
end