Class: WKCheck::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/wkcheck/stats.rb

Instance Method Summary collapse

Instance Method Details

#level_progressionObject



17
18
19
20
21
22
# File 'lib/wkcheck/stats.rb', line 17

def level_progression
  progress = Wanikani::Level.progression
  message = Rainbow("Your progress for level #{progress["current_level"]}:\n").green
  message += progression_message(progress, "radicals")
  message += progression_message(progress, "kanji")
end

#random_kanjiObject



24
25
26
27
28
29
30
# File 'lib/wkcheck/stats.rb', line 24

def random_kanji
  random_kanji = Wanikani::Level.kanji(random_level).sample
  message = Rainbow("Your random kanji is ").bright +  Rainbow(random_kanji['character']).bright.underline + "\n"
  message += Rainbow("Level: ").bright + random_kanji['level'].to_s + "\n"
  message += Rainbow("Meaning: ").bright + random_kanji['meaning'] + "\n"
  message += Rainbow("Reading (#{random_kanji['important_reading']}): ").bright + random_kanji[random_kanji['important_reading']]
end

#random_wordObject



32
33
34
35
36
37
38
# File 'lib/wkcheck/stats.rb', line 32

def random_word
  random_word = Wanikani::Level.vocabulary(random_level).sample
  message = Rainbow("Your random word is ").bright +  Rainbow(random_word['character']).bright.underline + "\n"
  message += Rainbow("Level: ").bright + random_word['level'].to_s + "\n"
  message += Rainbow("Meaning: ").bright + random_word['meaning'] + "\n"
  message += Rainbow("Reading: ").bright + random_word['kana']
end

#study_queueObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/wkcheck/stats.rb', line 3

def study_queue
  if Wanikani::User.on_vacation?
     = Wanikani::User.information
    vacation_date = Time.at(["vacation_date"]).localtime.strftime("%A, %B %-d at %-l:%M %p")
    Rainbow("You are currently on vacation from WaniKani, starting from #{Rainbow(vacation_date).bright}.").green
  else
    queue = Wanikani::StudyQueue.queue
    lessons = queue["lessons_available"]
    reviews = queue["reviews_available"]
    next_review_date = Time.at(queue["next_review_date"]).localtime.strftime("%A, %B %-d at %-l:%M %p")
    queue_message(lessons, reviews, next_review_date)
  end
end