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 |
# File 'lib/data_kit/csv/parser.rb', line 10 def initialize(path) @path = path set_handle 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
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/data_kit/csv/parser.rb', line 15 def each_row(&block) first = true handle.rewind ::CSV.parse(handle, converters: nil) do |row| if first == true first = false @headers = row else yield row end end end |