Class: WKCheck::CriticalItems

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

Instance Method Summary collapse

Constructor Details

#initialize(percentage) ⇒ CriticalItems

Returns a new instance of CriticalItems.



3
4
5
# File 'lib/wkcheck/critical_items.rb', line 3

def initialize(percentage)
  @percentage = percentage
end

Instance Method Details

#critical_itemsObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/wkcheck/critical_items.rb', line 7

def critical_items
  critical = Wanikani::CriticalItems.critical(@percentage).sort_by { |item| item["type"] }

  if critical.empty?
    Rainbow("Awesome, you have no items under #{@percentage} percent correct! Keep on rockin'!").bright.green
  else
    summary =  Rainbow("Your Critical Items - Max percentage: #{@percentage} ").bright.white
    summary += "(#{Rainbow('Kanji').red}, #{Rainbow('Radicals').cyan}, #{Rainbow('Vocabulary').magenta}):\n"
    summary += critical.map { |item| send("#{item["type"]}_info", item) }.compact.join("\n")
  end
end