class CoinSync::Outputs::Raw

Public Instance Methods

headers() click to toggle source
# File lib/coinsync/outputs/raw.rb, line 20
def headers
  [
    'Exchange',
    'Date',
    'Bought amount',
    'Bought currency',
    'Sold amount',
    'Sold currency'
  ]
end
process_transactions(transactions, *args) click to toggle source
# File lib/coinsync/outputs/raw.rb, line 10
def process_transactions(transactions, *args)
  CSV.open(@target_file, 'w', col_sep: @config.column_separator) do |csv|
    csv << headers

    transactions.each do |tx|
      csv << transaction_to_csv(tx)
    end
  end
end
transaction_to_csv(tx) click to toggle source
# File lib/coinsync/outputs/raw.rb, line 31
def transaction_to_csv(tx)
  [
    tx.exchange,
    @formatter.format_time(tx.time),
    tx.bought_currency.crypto? ?
      @formatter.format_crypto(tx.bought_amount) : @formatter.format_fiat(tx.bought_amount),
    tx.bought_currency.code,
    tx.sold_currency.crypto? ?
      @formatter.format_crypto(tx.sold_amount) : @formatter.format_fiat(tx.sold_amount),
    tx.sold_currency.code
  ]
end