Module: CoinSync::Transaction::Amounts
- Included in:
- CoinSync::Transaction, ConvertedAmounts
- Defined in:
- lib/coinsync/transaction.rb
Instance Attribute Summary collapse
-
#bought_amount ⇒ Object
readonly
Returns the value of attribute bought_amount.
-
#bought_currency ⇒ Object
readonly
Returns the value of attribute bought_currency.
-
#sold_amount ⇒ Object
readonly
Returns the value of attribute sold_amount.
-
#sold_currency ⇒ Object
readonly
Returns the value of attribute sold_currency.
Instance Method Summary collapse
- #crypto_amount ⇒ Object
- #crypto_currency ⇒ Object
- #fiat_amount ⇒ Object
- #fiat_currency ⇒ Object
- #price ⇒ Object
- #purchase? ⇒ Boolean
- #sale? ⇒ Boolean
- #swap? ⇒ Boolean
- #type ⇒ Object
Instance Attribute Details
#bought_amount ⇒ Object (readonly)
Returns the value of attribute bought_amount.
12 13 14 |
# File 'lib/coinsync/transaction.rb', line 12 def bought_amount @bought_amount end |
#bought_currency ⇒ Object (readonly)
Returns the value of attribute bought_currency.
12 13 14 |
# File 'lib/coinsync/transaction.rb', line 12 def bought_currency @bought_currency end |
#sold_amount ⇒ Object (readonly)
Returns the value of attribute sold_amount.
12 13 14 |
# File 'lib/coinsync/transaction.rb', line 12 def sold_amount @sold_amount end |
#sold_currency ⇒ Object (readonly)
Returns the value of attribute sold_currency.
12 13 14 |
# File 'lib/coinsync/transaction.rb', line 12 def sold_currency @sold_currency end |
Instance Method Details
#crypto_amount ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/coinsync/transaction.rb', line 46 def crypto_amount case type when TYPE_PURCHASE then bought_amount when TYPE_SALE then sold_amount else raise "Operation not supported for crypto swap transactions" end end |
#crypto_currency ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/coinsync/transaction.rb', line 62 def crypto_currency case type when TYPE_PURCHASE then bought_currency when TYPE_SALE then sold_currency else raise "Operation not supported for crypto swap transactions" end end |
#fiat_amount ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/coinsync/transaction.rb', line 38 def fiat_amount case type when TYPE_PURCHASE then sold_amount when TYPE_SALE then bought_amount else raise "Operation not supported for crypto swap transactions" end end |
#fiat_currency ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/coinsync/transaction.rb', line 54 def fiat_currency case type when TYPE_PURCHASE then sold_currency when TYPE_SALE then bought_currency else raise "Operation not supported for crypto swap transactions" end end |
#price ⇒ Object
70 71 72 |
# File 'lib/coinsync/transaction.rb', line 70 def price fiat_amount / crypto_amount end |
#purchase? ⇒ Boolean
26 27 28 |
# File 'lib/coinsync/transaction.rb', line 26 def purchase? type == TYPE_PURCHASE end |
#sale? ⇒ Boolean
30 31 32 |
# File 'lib/coinsync/transaction.rb', line 30 def sale? type == TYPE_SALE end |
#swap? ⇒ Boolean
34 35 36 |
# File 'lib/coinsync/transaction.rb', line 34 def swap? type == TYPE_SWAP end |
#type ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/coinsync/transaction.rb', line 14 def type if bought_currency.crypto? if sold_currency.crypto? return TYPE_SWAP else return TYPE_PURCHASE end else return TYPE_SALE end end |