Class: CoinSync::Importers::BitBay20::HistoryEntry
- Inherits:
-
Object
- Object
- CoinSync::Importers::BitBay20::HistoryEntry
- Defined in:
- lib/coinsync/importers/bitbay20.rb
Constant Summary collapse
- POLISH_TIMEZONE =
TZInfo::Timezone.get('Europe/Warsaw')
Instance Attribute Summary collapse
-
#accounting_date ⇒ Object
Returns the value of attribute accounting_date.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#date ⇒ Object
Returns the value of attribute date.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #crypto? ⇒ Boolean
- #fiat? ⇒ Boolean
-
#initialize(line) ⇒ HistoryEntry
constructor
A new instance of HistoryEntry.
- #parse_currency(code) ⇒ Object
Constructor Details
#initialize(line) ⇒ HistoryEntry
Returns a new instance of HistoryEntry.
30 31 32 33 34 35 36 37 38 39 |
# 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 |
Instance Attribute Details
#accounting_date ⇒ Object
Returns the value of attribute accounting_date.
26 27 28 |
# File 'lib/coinsync/importers/bitbay20.rb', line 26 def accounting_date @accounting_date end |
#amount ⇒ Object
Returns the value of attribute amount.
26 27 28 |
# File 'lib/coinsync/importers/bitbay20.rb', line 26 def amount @amount end |
#currency ⇒ Object
Returns the value of attribute currency.
26 27 28 |
# File 'lib/coinsync/importers/bitbay20.rb', line 26 def currency @currency end |
#date ⇒ Object
Returns the value of attribute date.
26 27 28 |
# File 'lib/coinsync/importers/bitbay20.rb', line 26 def date @date end |
#type ⇒ Object
Returns the value of attribute type.
26 27 28 |
# File 'lib/coinsync/importers/bitbay20.rb', line 26 def type @type end |
Instance Method Details
#crypto? ⇒ Boolean
41 42 43 |
# File 'lib/coinsync/importers/bitbay20.rb', line 41 def crypto? @currency.crypto? end |
#fiat? ⇒ Boolean
45 46 47 |
# File 'lib/coinsync/importers/bitbay20.rb', line 45 def fiat? @currency.fiat? end |
#parse_currency(code) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# 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 |