Class: AnkiTranslator::CardsHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/vocab_to_anki/cards_helper.rb

Defined Under Namespace

Classes: Note

Constant Summary collapse

DEFAULT_INPUT_FILE =
"input.csv"
DEFAULT_OUTPUT_FILE =
"output.csv"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_file = DEFAULT_INPUT_FILE, output_file = DEFAULT_OUTPUT_FILE) ⇒ CardsHelper

Returns a new instance of CardsHelper.



12
13
14
15
16
# File 'lib/vocab_to_anki/cards_helper.rb', line 12

def initialize(input_file = DEFAULT_INPUT_FILE, output_file = DEFAULT_OUTPUT_FILE)
  @notes = parse(input_file)
  @total = @notes.count
  @output_file = output_file
end

Instance Attribute Details

#notesObject

Returns the value of attribute notes.



10
11
12
# File 'lib/vocab_to_anki/cards_helper.rb', line 10

def notes
  @notes
end

Instance Method Details

#generate_csv_file(start_at = 0, end_at = total) ⇒ Object



18
19
20
21
22
23
# File 'lib/vocab_to_anki/cards_helper.rb', line 18

def generate_csv_file(start_at = 0, end_at = total)
  add_definitions_and_translations(start_at, end_at)
  print_stats(notes[start_at..end_at])
  cards = anki_cards(notes[start_at..end_at])
  write(cards, "#{start_at}-#{end_at}-#{output_file}")
end