Class: CoinSync::Importers::Kraken::LedgerEntry
- Inherits:
-
Object
- Object
- CoinSync::Importers::Kraken::LedgerEntry
- Defined in:
- lib/coinsync/importers/kraken_common.rb
Instance Attribute Summary collapse
-
#aclass ⇒ Object
Returns the value of attribute aclass.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#asset ⇒ Object
Returns the value of attribute asset.
-
#balance ⇒ Object
Returns the value of attribute balance.
-
#fee ⇒ Object
Returns the value of attribute fee.
-
#refid ⇒ Object
Returns the value of attribute refid.
-
#time ⇒ Object
Returns the value of attribute time.
-
#txid ⇒ Object
Returns the value of attribute txid.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#aclass ⇒ Object
Returns the value of attribute aclass.
11 12 13 |
# File 'lib/coinsync/importers/kraken_common.rb', line 11 def aclass @aclass end |
#amount ⇒ Object
Returns the value of attribute amount.
11 12 13 |
# File 'lib/coinsync/importers/kraken_common.rb', line 11 def amount @amount end |
#asset ⇒ Object
Returns the value of attribute asset.
11 12 13 |
# File 'lib/coinsync/importers/kraken_common.rb', line 11 def asset @asset end |
#balance ⇒ Object
Returns the value of attribute balance.
11 12 13 |
# File 'lib/coinsync/importers/kraken_common.rb', line 11 def balance @balance end |
#fee ⇒ Object
Returns the value of attribute fee.
11 12 13 |
# File 'lib/coinsync/importers/kraken_common.rb', line 11 def fee @fee end |
#refid ⇒ Object
Returns the value of attribute refid.
11 12 13 |
# File 'lib/coinsync/importers/kraken_common.rb', line 11 def refid @refid end |
#time ⇒ Object
Returns the value of attribute time.
11 12 13 |
# File 'lib/coinsync/importers/kraken_common.rb', line 11 def time @time end |
#txid ⇒ Object
Returns the value of attribute txid.
11 12 13 |
# File 'lib/coinsync/importers/kraken_common.rb', line 11 def txid @txid end |
#type ⇒ Object
Returns the value of attribute type.
11 12 13 |
# File 'lib/coinsync/importers/kraken_common.rb', line 11 def type @type end |
Class Method Details
.from_csv(line) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/coinsync/importers/kraken_common.rb', line 13 def self.from_csv(line) entry = self.new entry.txid = line[0] entry.refid = line[1] entry.time = Time.parse(line[2] + " +0000") entry.type = line[3] entry.aclass = line[4] entry.asset = parse_currency(line[5]) entry.amount = BigDecimal.new(line[6]) entry.fee = BigDecimal.new(line[7]) entry.balance = BigDecimal.new(line[8]) entry end |
.from_json(hash) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/coinsync/importers/kraken_common.rb', line 27 def self.from_json(hash) entry = self.new entry.refid = hash['refid'] entry.time = Time.at(hash['time']) entry.type = hash['type'] entry.aclass = hash['aclass'] entry.asset = parse_currency(hash['asset']) entry.amount = BigDecimal.new(hash['amount']) entry.fee = BigDecimal.new(hash['fee']) entry.balance = BigDecimal.new(hash['balance']) entry end |
.parse_currency(code) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/coinsync/importers/kraken_common.rb', line 40 def self.parse_currency(code) case code when 'BCH' then CryptoCurrency.new('BCH') when 'DASH' then CryptoCurrency.new('DASH') when 'EOS' then CryptoCurrency.new('EOS') when 'GNO' then CryptoCurrency.new('GNO') when 'KFEE' then CryptoCurrency.new('KFEE') when 'USDT' then CryptoCurrency.new('USDT') when 'XDAO' then CryptoCurrency.new('DAO') when 'XETC' then CryptoCurrency.new('ETC') when 'XETH' then CryptoCurrency.new('ETH') when 'XICN' then CryptoCurrency.new('ICN') when 'XLTC' then CryptoCurrency.new('LTC') when 'XMLN' then CryptoCurrency.new('MLN') when 'XNMC' then CryptoCurrency.new('NMC') when 'XREP' then CryptoCurrency.new('REP') when 'XXBT' then CryptoCurrency.new('BTC') when 'XXDG' then CryptoCurrency.new('DOGE') when 'XXLM' then CryptoCurrency.new('XLM') when 'XXMR' then CryptoCurrency.new('XMR') when 'XXRP' then CryptoCurrency.new('XRP') when 'XXVN' then CryptoCurrency.new('VEN') when 'XZEC' then CryptoCurrency.new('ZEC') when 'ZCAD' then FiatCurrency.new('CAD') when 'ZEUR' then FiatCurrency.new('EUR') when 'ZGBP' then FiatCurrency.new('GBP') when 'ZJPY' then FiatCurrency.new('JPY') when 'ZKRW' then FiatCurrency.new('KRW') when 'ZUSD' then FiatCurrency.new('USD') else raise "Unknown currency: #{code}" end end |
Instance Method Details
#crypto? ⇒ Boolean
76 77 78 |
# File 'lib/coinsync/importers/kraken_common.rb', line 76 def crypto? @asset.crypto? end |