Class: CoinSync::Importers::Circle

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

Defined Under Namespace

Classes: HistoryEntry

Instance Method Summary collapse

Methods inherited from Base

#can_build?, #initialize, register_commands, register_importer, registered_commands

Constructor Details

This class inherits a constructor from CoinSync::Importers::Base

Instance Method Details

#read_transaction_list(source) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/coinsync/importers/circle.rb', line 32

def read_transaction_list(source)
  csv = CSV.new(source, col_sep: ',')

  transactions = []

  csv.each do |line|
    next if line[0] == 'Date'

    entry = HistoryEntry.new(line)

    next if entry.type != 'deposit'

    transactions << Transaction.new(
      exchange: 'Circle',
      bought_currency: entry.to_currency,
      sold_currency: entry.from_currency,
      time: entry.date,
      bought_amount: entry.to_amount,
      sold_amount: entry.from_amount
    )
  end

  transactions
end