Sha256: 4d116ca074602e1ba2701810fd40aa93aaf3b87e0405cce9e028a762f62cde9b

Contents?: true

Size: 596 Bytes

Versions: 1

Compression:

Stored size: 596 Bytes

Contents

module PayoneerCsv

  class PdfReader
    attr_reader :file_path

    def initialize(file_path)
      @file_path = file_path
    end

    def read
      transactions = []

      raw_data.each_line do |row|
        match_data = parse(row)
        next unless match_data

        transactions << Transaction.new(match_data)
      end

      transactions
    end

    def raw_data
      `ps2ascii #{file_path}`
    end

    def parse(row)
      row.match /^(?<created_at>\d{1,2}\/\d{1,2}\/\d{4} \d{1,2}:\d{2}:\d{2} (AM|PM))\s(?<description>.+) (?<amount>-?(\d|,)+\.\d{2})\s+USD$/
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
payoneer_csv-0.1.4 lib/payoneer_csv/pdf_reader.rb