Class: SoapyBing::Ads::Reports::Parsers::CSVParser
- Inherits:
-
Object
- Object
- SoapyBing::Ads::Reports::Parsers::CSVParser
- Defined in:
- lib/soapy_bing/ads/reports/parsers/csv_parser.rb
Defined Under Namespace
Classes: FormatError
Constant Summary collapse
- CSV_PAYLOAD_OFFSET_FRONT =
First 10 csv lines are report metadata
10
- CSV_PAYLOAD_OFFSET_BACK =
Last 2 csv lines are Microsoft copyright
2
Instance Method Summary collapse
-
#initialize(raw) ⇒ CSVParser
constructor
A new instance of CSVParser.
- #rows ⇒ Object
Constructor Details
#initialize(raw) ⇒ CSVParser
Returns a new instance of CSVParser.
14 15 16 |
# File 'lib/soapy_bing/ads/reports/parsers/csv_parser.rb', line 14 def initialize(raw) @raw = raw end |
Instance Method Details
#rows ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/soapy_bing/ads/reports/parsers/csv_parser.rb', line 18 def rows @rows ||= begin header, *body = extract_csv_payload raise FormatError if body.size != payload_rows_number body.map { |row| header.zip(row).to_h } end end |