Class: Pipeline::Parser::CSVParser
Instance Attribute Summary collapse
-
#attribute_matrix ⇒ Object
Returns the value of attribute attribute_matrix.
-
#items ⇒ Object
Returns the value of attribute items.
-
#model ⇒ Object
Returns the value of attribute model.
Instance Method Summary collapse
- #coerce(input, output) ⇒ Object
-
#initialize ⇒ CSVParser
constructor
A new instance of CSVParser.
- #match(attribute, prok) ⇒ Object
- #parse(file_path, options = {}) ⇒ Object
- #register_model(model) ⇒ Object
Constructor Details
#initialize ⇒ CSVParser
Returns a new instance of CSVParser.
12 13 14 15 |
# File 'lib/etl-pipeline.rb', line 12 def initialize @attribute_matrix = Hash.new @items = Array.new end |
Instance Attribute Details
#attribute_matrix ⇒ Object
Returns the value of attribute attribute_matrix.
11 12 13 |
# File 'lib/etl-pipeline.rb', line 11 def attribute_matrix @attribute_matrix end |
#items ⇒ Object
Returns the value of attribute items.
11 12 13 |
# File 'lib/etl-pipeline.rb', line 11 def items @items end |
#model ⇒ Object
Returns the value of attribute model.
11 12 13 |
# File 'lib/etl-pipeline.rb', line 11 def model @model end |
Instance Method Details
#coerce(input, output) ⇒ Object
17 18 19 20 |
# File 'lib/etl-pipeline.rb', line 17 def coerce(input, output) @attribute_matrix.each do |attr, prok| end end |
#match(attribute, prok) ⇒ Object
34 35 36 |
# File 'lib/etl-pipeline.rb', line 34 def match(attribute, prok) @attribute_matrix[attribute.to_sym] = prok end |
#parse(file_path, options = {}) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/etl-pipeline.rb', line 22 def parse(file_path, ={}) CSV.foreach(file_path, ) do |csv| obj = @model.new coerce csv, obj yield csv end end |
#register_model(model) ⇒ Object
30 31 32 |
# File 'lib/etl-pipeline.rb', line 30 def register_model(model) self.model = model end |