Sha256: 640b8bafe749bd466b7fcec395711f09f4cd55ebfdb3ff16bfa4aa80e4f8b155

Contents?: true

Size: 540 Bytes

Versions: 4

Compression:

Stored size: 540 Bytes

Contents

module PayoneerCsv

  class Csv
    attr_reader :transactions

    def initialize(transactions)
      @transactions = transactions
    end

    def generate
      CSV.generate do |csv|
        csv << ['Transaction Date', 'Description', 'Amount', 'Currency']

        transactions.each do |transaction|
          csv << row_for(transaction)
        end
      end
    end

    private

    def row_for(transaction)
      row = [:created_at, :description, :amount].map { |field| transaction.send(field) }
      row << 'USD'
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
payoneer_csv-0.1.4 lib/payoneer_csv/csv.rb
payoneer_csv-0.1.2 lib/payoneer_csv/csv.rb
payoneer_csv-0.1.1 lib/payoneer_csv/csv.rb
payoneer_csv-0.1.0 lib/payoneer_csv/csv.rb