Class: Peddler::CSVParser Private
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Peddler::CSVParser
- Defined in:
- lib/peddler/csv_parser.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #content ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(res) ⇒ CSVParser
constructor
private
A new instance of CSVParser.
- #parse ⇒ Object private
- #records_count ⇒ Object private
- #valid? ⇒ Boolean private
Constructor Details
#initialize(res) ⇒ CSVParser
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of CSVParser.
10 11 12 13 |
# File 'lib/peddler/csv_parser.rb', line 10 def initialize(res) super(res) split_body end |
Instance Attribute Details
#content ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/peddler/csv_parser.rb', line 8 def content @content end |
Instance Method Details
#parse ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 18 |
# File 'lib/peddler/csv_parser.rb', line 15 def parse # http://stackoverflow.com/questions/8073920/importing-csv-quoting-error-is-driving-me-nuts CSV.parse(content, col_sep: "\t", quote_char: "\x00", headers: true) if content end |
#records_count ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'lib/peddler/csv_parser.rb', line 20 def records_count Hash[summary.split("\n\t")[1, 2].map { |line| line.split("\t\t") }] end |
#valid? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 |
# File 'lib/peddler/csv_parser.rb', line 24 def valid? headers['Content-MD5'] == Digest::MD5.base64digest(body) end |