Module: AnkiRecord::Anki21DatabaseConstructors

Included in:
Anki21Database
Defined in:
lib/anki_record/anki21_database/anki21_database_constructors.rb

Overview

:nodoc:

Constant Summary collapse

FILENAME =
"collection.anki21"

Instance Method Summary collapse

Instance Method Details

#create_initialize(anki_package:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/anki_record/anki21_database/anki21_database_constructors.rb', line 7

def create_initialize(anki_package:)
  @anki_package = anki_package
  @database = SQLite3::Database.new "#{anki_package.tmpdir}/#{FILENAME}", options: {}
  database.execute_batch ANKI_SCHEMA_DEFINITION
  database.execute INSERT_COLLECTION_ANKI_21_COL_RECORD
  database.results_as_hash = true
  @collection = Collection.new(anki21_database: self)
  initialize_note_types
  initialize_deck_options_groups
  initialize_decks
end

#update_initialize(anki_package:) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/anki_record/anki21_database/anki21_database_constructors.rb', line 19

def update_initialize(anki_package:)
  @anki_package = anki_package
  @database = SQLite3::Database.new("#{anki_package.tmpdir}/#{FILENAME}", options: {})
  database.results_as_hash = true
  @collection = Collection.new(anki21_database: self)
  initialize_note_types
  initialize_deck_options_groups
  initialize_decks
end