Class: DataKit::CSV::Parser
- Inherits:
-
Object
- Object
- DataKit::CSV::Parser
- Defined in:
- lib/data_kit/csv/parser.rb
Instance Attribute Summary collapse
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #each_row(&block) ⇒ Object
-
#initialize(path) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(path) ⇒ Parser
Returns a new instance of Parser.
10 11 12 13 14 15 |
# File 'lib/data_kit/csv/parser.rb', line 10 def initialize(path) @path = path set_handle set_headers end |
Instance Attribute Details
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
7 8 9 |
# File 'lib/data_kit/csv/parser.rb', line 7 def handle @handle end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
8 9 10 |
# File 'lib/data_kit/csv/parser.rb', line 8 def headers @headers end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/data_kit/csv/parser.rb', line 6 def path @path end |
Instance Method Details
#each_row(&block) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/data_kit/csv/parser.rb', line 17 def each_row(&block) handle.rewind Rcsv.parse(handle, :header => :skip, :columns => columns, :row_as_hash => true) do |row| puts row.inspect yield row end end |