class Paypal::Csv::Reports::CaseReport
Attributes
account_id[R]
entries[R]
generated_at[R]
header[R]
reporting_window[R]
version[R]
Public Class Methods
build(file)
click to toggle source
# File lib/paypal/csv/reports/case_report.rb, line 7 def self.build(file) new(File.open(file, 'r:bom|utf-8')) end
new(csv)
click to toggle source
# File lib/paypal/csv/reports/case_report.rb, line 13 def initialize(csv) @entries = [] parse(csv) end
Private Instance Methods
parse(csv)
click to toggle source
# File lib/paypal/csv/reports/case_report.rb, line 21 def parse(csv) ::CSV.parse(csv) { |row| parse_row(row) } end
parse_header(row)
click to toggle source
# File lib/paypal/csv/reports/case_report.rb, line 42 def parse_header(row) row.map { |v| v.downcase.gsub(' ', '_').to_sym } end
parse_report_header(row)
click to toggle source
# File lib/paypal/csv/reports/case_report.rb, line 38 def parse_report_header(row) @generated_at, @reporting_window, @account_id, @version = row end
parse_row(row)
click to toggle source
# File lib/paypal/csv/reports/case_report.rb, line 25 def parse_row(row) row_type = row.shift.to_s.strip case row_type when 'RH' parse_report_header(row) when 'CH' @header = parse_header(row) when 'SB' @entries << Hash[@header.zip(row)] end end