Class: Anki::Card
- Inherits:
-
Object
- Object
- Anki::Card
- Defined in:
- lib/ankirb/anki/card.rb
Instance Attribute Summary collapse
-
#deck ⇒ Object
Returns the value of attribute deck.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#tags ⇒ Object
Returns the value of attribute tags.
Instance Method Summary collapse
- #back ⇒ Object (also: #answer)
- #back=(value) ⇒ Object (also: #answer=)
- #front ⇒ Object (also: #question)
- #front=(value) ⇒ Object (also: #question=)
-
#has_media? ⇒ Boolean
is media attached to this card?.
-
#initialize(options = {}) ⇒ Card
constructor
A new instance of Card.
- #initialize_copy(orig) ⇒ Object
-
#invert ⇒ Object
returns a new card with the front and back of the original inverted.
-
#invert! ⇒ Object
flips the front and back of this card.
Constructor Details
Instance Attribute Details
#deck ⇒ Object
Returns the value of attribute deck.
3 4 5 |
# File 'lib/ankirb/anki/card.rb', line 3 def deck @deck end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/ankirb/anki/card.rb', line 4 def id @id end |
#tags ⇒ Object
Returns the value of attribute tags.
3 4 5 |
# File 'lib/ankirb/anki/card.rb', line 3 def @tags end |
Instance Method Details
#back ⇒ Object Also known as: answer
18 19 20 |
# File 'lib/ankirb/anki/card.rb', line 18 def back @back end |
#back=(value) ⇒ Object Also known as: answer=
48 49 50 51 52 53 54 |
# File 'lib/ankirb/anki/card.rb', line 48 def back= value if value.is_a? String @back.content = value else @back = value end end |
#front ⇒ Object Also known as: question
14 15 16 |
# File 'lib/ankirb/anki/card.rb', line 14 def front @front end |
#front=(value) ⇒ Object Also known as: question=
40 41 42 43 44 45 46 |
# File 'lib/ankirb/anki/card.rb', line 40 def front= value if value.is_a? String @front.content = value else @front = value end end |
#has_media? ⇒ Boolean
is media attached to this card?
36 37 38 |
# File 'lib/ankirb/anki/card.rb', line 36 def has_media? !@front.media.empty? or !back.media.empty? end |
#initialize_copy(orig) ⇒ Object
56 57 58 59 60 |
# File 'lib/ankirb/anki/card.rb', line 56 def initialize_copy orig super @front = Marshal.load(Marshal.dump(orig.front)) @back = Marshal.load(Marshal.dump(orig.back)) end |
#invert ⇒ Object
returns a new card with the front and back of the original inverted
23 24 25 26 27 28 |
# File 'lib/ankirb/anki/card.rb', line 23 def invert c = Anki::Card.new(front: @back.to_s, back: @front.to_s) c.front = @back.dup c.back = @front.dup c end |
#invert! ⇒ Object
flips the front and back of this card
31 32 33 |
# File 'lib/ankirb/anki/card.rb', line 31 def invert! @front, @back = @back, @front end |