class Trader::Price
Attributes
amount[R]
currency[R]
Public Class Methods
new(_currency, _amount)
click to toggle source
# File lib/trade-o-matic/structs/price.rb, line 5 def initialize(_currency, _amount) @currency = Currency.for_code _currency @amount = Standard.amount _amount end
Public Instance Methods
convert_to(_other_currency)
click to toggle source
# File lib/trade-o-matic/structs/price.rb, line 14 def convert_to(_other_currency) _other_currency = Currency.for_code _other_currency return self if _other_currency == currency new_amount = @currency.convert amount, _other_currency Price.new _other_currency, new_amount end
pack(_amount)
click to toggle source
# File lib/trade-o-matic/structs/price.rb, line 10 def pack(_amount) currency.pack _amount end
to_s()
click to toggle source
# File lib/trade-o-matic/structs/price.rb, line 23 def to_s "#{amount} #{currency.code}" end