class Stellar::Amount
Attributes
amount[R]
asset[R]
Public Class Methods
new(amount, asset = Stellar::Asset.native)
click to toggle source
@param [Fixnum] amount @param [Stellar::Asset] asset
# File lib/stellar/amount.rb, line 8 def initialize(amount, asset = Stellar::Asset.native) # TODO: how are we going to handle decimal considerations? @amount = amount @asset = asset end
Public Instance Methods
inspect()
click to toggle source
# File lib/stellar/amount.rb, line 32 def inspect "#<Stellar::Amount #{asset}(#{amount})>" end
to_payment()
click to toggle source
@return [Array(Symbol, Fixnum)] in case of a native asset @return [Array(Symbol, String, Stellar::KeyPair, Fixnum)] in case of alphanum asset
# File lib/stellar/amount.rb, line 17 def to_payment case asset.type when AssetType.asset_type_native [:native, amount] when AssetType.asset_type_credit_alphanum4 keypair = KeyPair.from_public_key(asset.issuer.value) [:alphanum4, asset.code, keypair, amount] when AssetType.asset_type_credit_alphanum12 keypair = KeyPair.from_public_key(asset.issuer.value) [:alphanum12, asset.code, keypair, amount] else raise "Unknown asset type: #{asset.type}" end end