class Anki::Deck
Attributes
cards[R]
desc[RW]
id[R]
name[RW]
Public Class Methods
new(name)
click to toggle source
# File lib/ankirb/anki/deck.rb, line 6 def initialize name @name = name @id = Anki::Helper.get_id initialize_cards end
Public Instance Methods
[](id)
click to toggle source
# File lib/ankirb/anki/deck.rb, line 50 def [] id @cards[id] end
add_card(card)
click to toggle source
adds a card to the deck
# File lib/ankirb/anki/deck.rb, line 25 def add_card card card.deck = self @cards[card.id] = card end
add_card_with_inversion(card)
click to toggle source
adds a card, and then inserts the inverted version of the card immediately after
# File lib/ankirb/anki/deck.rb, line 31 def add_card_with_inversion card add_card card add_card card.invert end
add_inversions()
click to toggle source
add inverted versions of the cards at the end of the deck
# File lib/ankirb/anki/deck.rb, line 37 def add_inversions @cards.values.each {|c| add_card c.invert } end
initialize_cards()
click to toggle source
# File lib/ankirb/anki/deck.rb, line 12 def initialize_cards @cards = {} #change @cards#to_s to prevent recursive output via parent / child relationship class << @cards def to_s "#< #{self.keys.count} cards>" end alias_method :inspect, :to_s end end
initialize_copy(orig)
click to toggle source
Calls superclass method
# File lib/ankirb/anki/deck.rb, line 54 def initialize_copy(orig) super initialize_cards orig.cards.each { |c| add_card c.dup } end
invert!()
click to toggle source
invert the faces of every card in place
# File lib/ankirb/anki/deck.rb, line 42 def invert! @cards.values.each {|c| c.invert! } end