Class: Anki::Importer::Deck
- Inherits:
-
Object
- Object
- Anki::Importer::Deck
- Defined in:
- lib/anki/importer/deck.rb
Overview
The root of the Anki object graph.
Instance Attribute Summary collapse
-
#card_models ⇒ Object
All the card models (schemas for cards) in the deck.
-
#card_models_by_id ⇒ Object
readonly
:nodoc: private.
-
#facts ⇒ Object
All the facts (associations) in the deck.
-
#facts_by_id ⇒ Object
readonly
:nodoc: private.
-
#fields ⇒ Object
All the fields (fact schema elements) in the deck.
-
#fields_by_id ⇒ Object
readonly
:nodoc: private.
-
#models ⇒ Object
All the models in the deck.
-
#models_by_id ⇒ Object
readonly
:nodoc: private.
Class Method Summary collapse
-
.from_db(deck_db) ⇒ Object
Reads an Anki deck database.
-
.from_file(deck_path) ⇒ Object
Reads an Anki deck database.
Instance Method Summary collapse
-
#initialize ⇒ Deck
constructor
:nodoc: private.
Constructor Details
#initialize ⇒ Deck
:nodoc: private
48 49 50 51 52 53 |
# File 'lib/anki/importer/deck.rb', line 48 def initialize @models_by_id = {} @fields_by_id = {} @card_models_by_id = {} @facts_by_id = {} end |
Instance Attribute Details
#card_models ⇒ Object
All the card models (schemas for cards) in the deck.
15 16 17 |
# File 'lib/anki/importer/deck.rb', line 15 def card_models @card_models end |
#card_models_by_id ⇒ Object (readonly)
:nodoc: private
77 78 79 |
# File 'lib/anki/importer/deck.rb', line 77 def card_models_by_id @card_models_by_id end |
#facts ⇒ Object
All the facts (associations) in the deck.
9 10 11 |
# File 'lib/anki/importer/deck.rb', line 9 def facts @facts end |
#facts_by_id ⇒ Object (readonly)
:nodoc: private
85 86 87 |
# File 'lib/anki/importer/deck.rb', line 85 def facts_by_id @facts_by_id end |
#fields ⇒ Object
All the fields (fact schema elements) in the deck.
13 14 15 |
# File 'lib/anki/importer/deck.rb', line 13 def fields @fields end |
#fields_by_id ⇒ Object (readonly)
:nodoc: private
69 70 71 |
# File 'lib/anki/importer/deck.rb', line 69 def fields_by_id @fields_by_id end |
#models ⇒ Object
All the models in the deck.
11 12 13 |
# File 'lib/anki/importer/deck.rb', line 11 def models @models end |
#models_by_id ⇒ Object (readonly)
:nodoc: private
61 62 63 |
# File 'lib/anki/importer/deck.rb', line 61 def models_by_id @models_by_id end |
Class Method Details
.from_db(deck_db) ⇒ Object
Reads an Anki deck database.
Args:
deck_db:: a Sqlite3::Datbase
Returns a deck.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/anki/importer/deck.rb', line 34 def self.from_db(deck_db) deck = self.new deck.models = Model.from_db deck_db deck.fields = Field.from_db deck_db, deck deck.fields.each { |field| field.model.add_field field } deck.card_models = CardModel.from_db deck_db, deck deck.card_models.each { |cmodel| cmodel.model.add_card_model cmodel } deck.facts = Fact.from_db deck_db, deck deck.facts.each { |fact| fact.model.add_fact fact } deck end |
.from_file(deck_path) ⇒ Object
Reads an Anki deck database.
Args:
deck_path:: path to an Anki deck on the filesystem
Returns a deck.
23 24 25 26 |
# File 'lib/anki/importer/deck.rb', line 23 def self.from_file(deck_path) deck_db = SQLite3::Database.new deck_path from_db deck_db end |