Class: CoinSync::Importers::BitBayAPI::HistoryEntry

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ HistoryEntry

Returns a new instance of HistoryEntry.



34
35
36
37
38
39
# File 'lib/coinsync/importers/bitbay_api.rb', line 34

def initialize(hash)
  @date = POLISH_TIMEZONE.local_to_utc(Time.parse(hash['time']))
  @amount = BigDecimal.new(hash['amount'])
  @type = hash['operation_type']
  @currency = parse_currency(hash['currency'])
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



32
33
34
# File 'lib/coinsync/importers/bitbay_api.rb', line 32

def amount
  @amount
end

#currencyObject

Returns the value of attribute currency.



32
33
34
# File 'lib/coinsync/importers/bitbay_api.rb', line 32

def currency
  @currency
end

#dateObject

Returns the value of attribute date.



32
33
34
# File 'lib/coinsync/importers/bitbay_api.rb', line 32

def date
  @date
end

#typeObject

Returns the value of attribute type.



32
33
34
# File 'lib/coinsync/importers/bitbay_api.rb', line 32

def type
  @type
end

Instance Method Details

#crypto?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/coinsync/importers/bitbay_api.rb', line 41

def crypto?
  @currency.crypto?
end

#fiat?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/coinsync/importers/bitbay_api.rb', line 45

def fiat?
  @currency.fiat?
end

#parse_currency(code) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/coinsync/importers/bitbay_api.rb', line 49

def parse_currency(code)
  case code.upcase

  when 'BCC' then CryptoCurrency.new('BCH')
  when 'BTC' then CryptoCurrency.new('BTC')
  when 'BTG' then CryptoCurrency.new('BTG')
  when 'DASH' then CryptoCurrency.new('DASH')
  when 'ETH' then CryptoCurrency.new('ETH')
  when 'GAME' then CryptoCurrency.new('GAME')
  when 'KZC' then CryptoCurrency.new('KZC')
  when 'LSK' then CryptoCurrency.new('LSK')
  when 'LTC' then CryptoCurrency.new('LTC')
  when 'XIN' then CryptoCurrency.new('XIN')
  when 'XRP' then CryptoCurrency.new('XRP')

  when 'EUR' then FiatCurrency.new('EUR')
  when 'USD' then FiatCurrency.new('USD')
  when 'PLN' then FiatCurrency.new('PLN')

  else raise "Unknown currency: #{code}"
  end
end