Class: CSVMagic::Importer

Inherits:
Object
  • Object
show all
Defined in:
lib/csv_magic/importer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, options) ⇒ Importer

Returns a new instance of Importer.



5
6
7
8
9
10
11
12
13
# File 'lib/csv_magic/importer.rb', line 5

def initialize(params, options)
  @file_handler = FileHandler.new()

  if @file_handler.save_temp_file(params[options[:file_field]])
    set_attributes_from_valid_file(options)
  else
    raise MissingFileContentsError
  end
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



3
4
5
# File 'lib/csv_magic/importer.rb', line 3

def filename
  @filename
end

#map_fieldsObject (readonly)

Returns the value of attribute map_fields.



3
4
5
# File 'lib/csv_magic/importer.rb', line 3

def map_fields
  @map_fields
end

Instance Method Details

#raw_dataObject



15
16
17
# File 'lib/csv_magic/importer.rb', line 15

def raw_data
  ::CSV.read(@file_handler.file_path, CSVMagic.options)
end