Class: Saru::Anki
- Inherits:
-
Object
- Object
- Saru::Anki
- Defined in:
- lib/saru/anki.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
Instance Method Summary collapse
- #deck ⇒ Object
- #generate ⇒ Object
-
#initialize(items) ⇒ Anki
constructor
A new instance of Anki.
Constructor Details
#initialize(items) ⇒ Anki
Returns a new instance of Anki.
8 9 10 |
# File 'lib/saru/anki.rb', line 8 def initialize items @items = items end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
6 7 8 |
# File 'lib/saru/anki.rb', line 6 def items @items end |
Instance Method Details
#deck ⇒ Object
12 13 14 15 16 17 |
# File 'lib/saru/anki.rb', line 12 def deck raise NotImplementedError, 'Radicals not supported' if items.first.is_a?(Saru::Radical) @deck ||= ::Anki::Deck.new card_headers: %w(front back tags), card_data: card_data end |
#generate ⇒ Object
19 20 21 22 23 24 |
# File 'lib/saru/anki.rb', line 19 def generate file_path = "saru_deck_#{}.txt" deck.generate_deck file: file_path puts "Anki file generated in #{file_path}" end |