Class: Peddler::FlatFileParser Private
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Peddler::FlatFileParser
- 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 }
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 ⇒ Object private
- #records_count ⇒ Object private
- #valid? ⇒ Boolean private
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.
13 14 15 16 17 |
# File 'lib/peddler/flat_file_parser.rb', line 13 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.
11 12 13 |
# File 'lib/peddler/flat_file_parser.rb', line 11 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.
11 12 13 |
# File 'lib/peddler/flat_file_parser.rb', line 11 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.
11 12 13 |
# File 'lib/peddler/flat_file_parser.rb', line 11 def summary @summary 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.
19 20 21 |
# File 'lib/peddler/flat_file_parser.rb', line 19 def parse CSV.parse(scrub_content, OPTIONS) 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.
23 24 25 |
# File 'lib/peddler/flat_file_parser.rb', line 23 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.
27 28 29 |
# File 'lib/peddler/flat_file_parser.rb', line 27 def valid? headers['Content-MD5'] == Digest::MD5.base64digest(body) end |