Class: AnkiRecord::Card

Inherits:
Object
  • Object
show all
Includes:
CardAttributes, Helpers::SharedConstantsHelper, Helpers::TimeHelper
Defined in:
lib/anki_record/card/card.rb

Overview

Card represents an Anki card. The cards are indirectly created when creating notes.

Instance Attribute Summary

Attributes included from CardAttributes

#anki21_database, #card_template, #data, #deck, #due, #factor, #flags, #id, #ivl, #lapses, #last_modified_timestamp, #left, #note, #odid, #odue, #queue, #reps, #type, #usn

Instance Method Summary collapse

Methods included from Helpers::TimeHelper

#milliseconds_since_epoch, #seconds_since_epoch

Constructor Details

#initialize(note:, card_template: nil, card_data: nil) ⇒ Card

:nodoc:



17
18
19
20
21
22
23
24
25
26
# File 'lib/anki_record/card/card.rb', line 17

def initialize(note:, card_template: nil, card_data: nil)
  @note = note
  if card_template
    setup_instance_variables_for_new_card(card_template:)
  elsif card_data
    setup_instance_variables_from_existing(card_data:)
  else
    raise ArgumentError
  end
end

Instance Method Details

#save(note_exists_already: false) ⇒ Object



28
29
30
# File 'lib/anki_record/card/card.rb', line 28

def save(note_exists_already: false)
  note_exists_already ? update_card_in_collection_anki21 : insert_new_card_in_collection_anki21
end