Class: CoinPortfolio::Transaction
- Inherits:
-
Object
- Object
- CoinPortfolio::Transaction
- Defined in:
- lib/coin_portfolio/transaction.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#native_amount ⇒ Object
Returns the value of attribute native_amount.
Instance Method Summary collapse
- #incoming? ⇒ Boolean
-
#initialize(amount:, native_amount:, incoming:) ⇒ Transaction
constructor
A new instance of Transaction.
- #price ⇒ Object
Constructor Details
#initialize(amount:, native_amount:, incoming:) ⇒ Transaction
5 6 7 8 9 |
# File 'lib/coin_portfolio/transaction.rb', line 5 def initialize(amount:, native_amount:, incoming:) @amount = amount @native_amount = native_amount @incoming = incoming end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
3 4 5 |
# File 'lib/coin_portfolio/transaction.rb', line 3 def amount @amount end |
#native_amount ⇒ Object
Returns the value of attribute native_amount.
3 4 5 |
# File 'lib/coin_portfolio/transaction.rb', line 3 def native_amount @native_amount end |
Instance Method Details
#incoming? ⇒ Boolean
16 17 18 |
# File 'lib/coin_portfolio/transaction.rb', line 16 def incoming? incoming end |
#price ⇒ Object
11 12 13 14 |
# File 'lib/coin_portfolio/transaction.rb', line 11 def price price_f = native_amount.amount.to_f / amount.amount CoinPortfolio::Money.new(amount: price_f, currency: native_amount.currency) end |