Class: Uncsv::Rows
- Inherits:
-
Object
- Object
- Uncsv::Rows
- Defined in:
- lib/uncsv/rows.rb
Overview
A collection of parsed rows from a CSV
Instance Method Summary collapse
-
#each {|row| ... } ⇒ Enumerator
Iterate over each row.
-
#header ⇒ Array
Get the CSV header.
-
#initialize(csv, config = nil) ⇒ Rows
constructor
Create a new
Rows
object.
Constructor Details
#initialize(csv, config = nil) ⇒ Rows
Create a new Rows
object
13 14 15 16 17 18 |
# File 'lib/uncsv/rows.rb', line 13 def initialize(csv, config = nil) @csv = csv @config = config || Config.new @started = false @parsed = nil end |
Instance Method Details
#each {|row| ... } ⇒ Enumerator
Iterate over each row
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/uncsv/rows.rb', line 25 def each(&block) Enumerator.new do |yielder| start index = parsed.index loop do break unless yield_row(yielder, index) index += 1 end end.each(&block) end |
#header ⇒ Array
Get the CSV header
41 42 43 |
# File 'lib/uncsv/rows.rb', line 41 def header parsed.header.to_a end |