Class: AnkiRecord::Collection

Inherits:
Object
  • Object
show all
Includes:
CollectionAttributes, Helpers::TimeHelper
Defined in:
lib/anki_record/collection/collection.rb

Overview

Collection represents the single record in the Anki collection.anki21 database’s ‘col` table. The note types, decks, and deck options groups data are contained within this record, but for simplicity of the gem’s API, they are managed by the Anki21Database class.

Instance Attribute Summary collapse

Attributes included from CollectionAttributes

#created_at_timestamp, #id, #last_modified_timestamp

Instance Method Summary collapse

Methods included from Helpers::TimeHelper

#milliseconds_since_epoch, #seconds_since_epoch

Constructor Details

#initialize(anki21_database:) ⇒ Collection

rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength :nodoc:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/anki_record/collection/collection.rb', line 25

def initialize(anki21_database:)
  @anki21_database = anki21_database
  @id = col_record["id"]
  @created_at_timestamp = col_record["crt"]
  @last_modified_timestamp = col_record["mod"]
  @scm = col_record["scm"]
  @ver = col_record["ver"]
  @dty = col_record["dty"]
  @usn = col_record["usn"]
  @ls = col_record["ls"]
  @configuration = JSON.parse(col_record["conf"])
  @tags = JSON.parse(col_record["tags"])
  remove_instance_variable(:@col_record)
end

Instance Attribute Details

#anki21_databaseObject (readonly)

Returns the value of attribute anki21_database.



20
21
22
# File 'lib/anki_record/collection/collection.rb', line 20

def anki21_database
  @anki21_database
end