Class: Peddler::FlatFileParser Private
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Peddler::FlatFileParser
- Includes:
- Headers
- Defined in:
- lib/peddler/flat_file_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.
Constant Summary collapse
- OPTIONS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
stackoverflow.com/questions/8073920/importing-csv-quoting-error-is-driving-me-nuts
{ col_sep: "\t", quote_char: "\x00", headers: true }.freeze
Instance Attribute Summary collapse
- #content ⇒ Object readonly private
- #encoding ⇒ Object readonly private
- #summary ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(res, encoding) ⇒ FlatFileParser
constructor
private
A new instance of FlatFileParser.
- #parse(&blk) ⇒ Object private
- #records_count ⇒ Object private
- #valid? ⇒ Boolean private
Methods included from Headers
#quota, #request_id, #response_context, #timestamp
Constructor Details
#initialize(res, encoding) ⇒ FlatFileParser
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 FlatFileParser.
16 17 18 19 20 |
# File 'lib/peddler/flat_file_parser.rb', line 16 def initialize(res, encoding) super(res) @encoding = encoding extract_content 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.
14 15 16 |
# File 'lib/peddler/flat_file_parser.rb', line 14 def content @content end |
#encoding ⇒ 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.
14 15 16 |
# File 'lib/peddler/flat_file_parser.rb', line 14 def encoding @encoding end |
#summary ⇒ 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.
14 15 16 |
# File 'lib/peddler/flat_file_parser.rb', line 14 def summary @summary end |
Instance Method Details
#parse(&blk) ⇒ 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.
22 23 24 |
# File 'lib/peddler/flat_file_parser.rb', line 22 def parse(&blk) CSV.parse(scrub_content, OPTIONS, &blk) 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.
26 27 28 |
# File 'lib/peddler/flat_file_parser.rb', line 26 def records_count summarize if summary? 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.
30 31 32 |
# File 'lib/peddler/flat_file_parser.rb', line 30 def valid? headers['Content-MD5'] == Digest::MD5.base64digest(body) end |