Class: CoinSync::Importers::Kraken::LedgerEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/coinsync/importers/kraken_common.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#aclassObject

Returns the value of attribute aclass.



11
12
13
# File 'lib/coinsync/importers/kraken_common.rb', line 11

def aclass
  @aclass
end

#amountObject

Returns the value of attribute amount.



11
12
13
# File 'lib/coinsync/importers/kraken_common.rb', line 11

def amount
  @amount
end

#assetObject

Returns the value of attribute asset.



11
12
13
# File 'lib/coinsync/importers/kraken_common.rb', line 11

def asset
  @asset
end

#balanceObject

Returns the value of attribute balance.



11
12
13
# File 'lib/coinsync/importers/kraken_common.rb', line 11

def balance
  @balance
end

#feeObject

Returns the value of attribute fee.



11
12
13
# File 'lib/coinsync/importers/kraken_common.rb', line 11

def fee
  @fee
end

#refidObject

Returns the value of attribute refid.



11
12
13
# File 'lib/coinsync/importers/kraken_common.rb', line 11

def refid
  @refid
end

#timeObject

Returns the value of attribute time.



11
12
13
# File 'lib/coinsync/importers/kraken_common.rb', line 11

def time
  @time
end

#txidObject

Returns the value of attribute txid.



11
12
13
# File 'lib/coinsync/importers/kraken_common.rb', line 11

def txid
  @txid
end

#typeObject

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

Returns:

  • (Boolean)


76
77
78
# File 'lib/coinsync/importers/kraken_common.rb', line 76

def crypto?
  @asset.crypto?
end