class CoinSync::Importers::BitBay20::HistoryEntry

Constants

POLISH_TIMEZONE

Attributes

accounting_date[RW]
amount[RW]
currency[RW]
date[RW]
type[RW]

Public Class Methods

new(line) click to toggle source
# File lib/coinsync/importers/bitbay20.rb, line 30
def initialize(line)
  @date = POLISH_TIMEZONE.local_to_utc(Time.parse(line[0])) unless line[0] == '-'
  @accounting_date = POLISH_TIMEZONE.local_to_utc(Time.parse(line[1])) unless line[1] == '-'

  @type = line[2]

  amount, currency = line[3].split(' ')
  @amount = BigDecimal.new(amount.gsub(/,/, ''))
  @currency = parse_currency(currency)
end

Public Instance Methods

crypto?() click to toggle source
# File lib/coinsync/importers/bitbay20.rb, line 41
def crypto?
  @currency.crypto?
end
fiat?() click to toggle source
# File lib/coinsync/importers/bitbay20.rb, line 45
def fiat?
  @currency.fiat?
end
parse_currency(code) click to toggle source
# File lib/coinsync/importers/bitbay20.rb, line 49
def parse_currency(code)
  case code
  when 'BTC' then CryptoCurrency.new('BTC')
  when 'ETH' then CryptoCurrency.new('ETH')
  when 'LSK' then CryptoCurrency.new('LSK')
  when 'LTC' then CryptoCurrency.new('LTC')
  when 'PLN' then FiatCurrency.new('PLN')
  else raise "Unknown currency: #{code}"
  end
end