Class: DataFile::Reader::CSV

Inherits:
Base
  • Object
show all
Defined in:
lib/data_file/reader/csv.rb

Instance Attribute Summary

Attributes inherited from Base

#reader

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from DataFile::Reader::Base

Instance Method Details

#headersObject



6
7
8
# File 'lib/data_file/reader/csv.rb', line 6

def headers
  @headers ||= (csv.headers rescue nil) || []
end

#rowsObject



10
11
12
13
14
# File 'lib/data_file/reader/csv.rb', line 10

def rows
  @rows ||= csv.each_with_object([]) do |row, array|
    array << (row.is_a?(::CSV::Row) ? row.to_hash.values : row)
  end
end