Class: CSVImporter::Importer
- Inherits:
-
Object
- Object
- CSVImporter::Importer
- Defined in:
- lib/csv_importer/csv_importer.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#csv_columns ⇒ Object
readonly
Returns the value of attribute csv_columns.
-
#delimiter ⇒ Object
readonly
Returns the value of attribute delimiter.
-
#dictionary ⇒ Object
readonly
Returns the value of attribute dictionary.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#objects(save = false) ⇒ Object
readonly
Returns the value of attribute objects.
-
#reader ⇒ Object
readonly
Returns the value of attribute reader.
-
#save ⇒ Object
readonly
Returns the value of attribute save.
Instance Method Summary collapse
-
#initialize(str_or_readable, klass = nil, dictionary = {}) ⇒ Importer
constructor
A new instance of Importer.
Constructor Details
#initialize(str_or_readable, klass = nil, dictionary = {}) ⇒ Importer
Returns a new instance of Importer.
9 10 11 12 13 14 15 16 17 |
# File 'lib/csv_importer/csv_importer.rb', line 9 def initialize(str_or_readable, klass=nil, dictionary={}) @klass = klass @save = save @dictionary = {} dictionary.each_pair{|k,v| @dictionary[k.downcase] = v.downcase} @delimiter, @csv_columns = determine_delimiter_and_columns(str_or_readable) @columns = match_columns @reader = CSV::Reader.create(str_or_readable, @delimiter) end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
7 8 9 |
# File 'lib/csv_importer/csv_importer.rb', line 7 def columns @columns end |
#csv_columns ⇒ Object (readonly)
Returns the value of attribute csv_columns.
7 8 9 |
# File 'lib/csv_importer/csv_importer.rb', line 7 def csv_columns @csv_columns end |
#delimiter ⇒ Object (readonly)
Returns the value of attribute delimiter.
7 8 9 |
# File 'lib/csv_importer/csv_importer.rb', line 7 def delimiter @delimiter end |
#dictionary ⇒ Object (readonly)
Returns the value of attribute dictionary.
7 8 9 |
# File 'lib/csv_importer/csv_importer.rb', line 7 def dictionary @dictionary end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
7 8 9 |
# File 'lib/csv_importer/csv_importer.rb', line 7 def klass @klass end |
#objects(save = false) ⇒ Object (readonly)
Returns the value of attribute objects.
7 8 9 |
# File 'lib/csv_importer/csv_importer.rb', line 7 def objects @objects end |
#reader ⇒ Object (readonly)
Returns the value of attribute reader.
7 8 9 |
# File 'lib/csv_importer/csv_importer.rb', line 7 def reader @reader end |
#save ⇒ Object (readonly)
Returns the value of attribute save.
7 8 9 |
# File 'lib/csv_importer/csv_importer.rb', line 7 def save @save end |