Class: Inkscape::Merge::DataParser::CSV

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/inkscape_merge/data_parsers.rb

Overview

CSV file parser Though Ruby’s CSV would suffice, we explicitly wrap it in an API Other parsers must comply to this API

Instance Method Summary collapse

Constructor Details

#initialize(data_file, csv_options) ⇒ CSV

Read file into memory



32
33
34
35
# File 'lib/inkscape_merge/data_parsers.rb', line 32

def initialize(data_file, csv_options)
  opts = csv_options
  @data = ::CSV.read data_file, opts
end

Instance Method Details

#each(&block) ⇒ Object

Wraps CSV#each for enumerable support



43
44
45
# File 'lib/inkscape_merge/data_parsers.rb', line 43

def each(&block)
  @data.each &block
end

#headersObject

Return headers as an array



38
39
40
# File 'lib/inkscape_merge/data_parsers.rb', line 38

def headers
  @data.headers
end