Class: CSVToSqlite::Parser
- Inherits:
-
Object
- Object
- CSVToSqlite::Parser
- Defined in:
- lib/csv_to_sqlite/parser.rb
Instance Attribute Summary collapse
-
#column_names ⇒ Object
readonly
Returns the value of attribute column_names.
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
-
#initialize(source, target, table_name = nil, column_names = nil) ⇒ Parser
constructor
A new instance of Parser.
- #parse! ⇒ Object
Constructor Details
#initialize(source, target, table_name = nil, column_names = nil) ⇒ Parser
Returns a new instance of Parser.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/csv_to_sqlite/parser.rb', line 14 def initialize(source, target, table_name=nil, column_names=nil) if File.exists?(source) @source = IO.readlines(source).to_s else @source = source end @target = target @table_name = table_name || 'item' @column_names = column_names || _name_columns(@source) _connect(@target) _create_model(@table_name, @column_names) DataMapper.finalize DataMapper.auto_migrate! end |
Instance Attribute Details
#column_names ⇒ Object (readonly)
Returns the value of attribute column_names.
12 13 14 |
# File 'lib/csv_to_sqlite/parser.rb', line 12 def column_names @column_names end |
#db ⇒ Object (readonly)
Returns the value of attribute db.
10 11 12 |
# File 'lib/csv_to_sqlite/parser.rb', line 10 def db @db end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
11 12 13 |
# File 'lib/csv_to_sqlite/parser.rb', line 11 def klass @klass end |
Instance Method Details
#parse! ⇒ Object
32 33 34 |
# File 'lib/csv_to_sqlite/parser.rb', line 32 def parse! _parse(@source) end |