Class: Hbtrack::Importer::AbstractImporter
- Inherits:
-
Object
- Object
- Hbtrack::Importer::AbstractImporter
- Defined in:
- lib/hbtrack/importer/abstract_importer.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#import_from(file) ⇒ Object
Import and parse the CSV from Streaks.
-
#initialize ⇒ AbstractImporter
constructor
A new instance of AbstractImporter.
-
#store_in(store) ⇒ Object
Store in database.
Constructor Details
#initialize ⇒ AbstractImporter
Returns a new instance of AbstractImporter.
7 8 9 10 |
# File 'lib/hbtrack/importer/abstract_importer.rb', line 7 def initialize @habits = {} @entries = {} end |
Instance Method Details
#import_from(file) ⇒ Object
Import and parse the CSV from Streaks
28 29 30 |
# File 'lib/hbtrack/importer/abstract_importer.rb', line 28 def import_from(file) raise 'Not implemented' end |
#store_in(store) ⇒ Object
Store in database
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/hbtrack/importer/abstract_importer.rb', line 13 def store_in(store) ids = {} @habits.each do |id, habit| ids[id] = store.add_habit(habit) end @entries.each do |key, entries| id = ids[key] entries.each do |entry| store.add_entry_of(id, entry) end end end |