Class: Wanikani::SRS

Inherits:
Object
  • Object
show all
Defined in:
lib/wanikani/srs.rb

Constant Summary collapse

ITEM_TYPES =
%w(apprentice guru master enlighten burned all)

Class Method Summary collapse

Class Method Details

.distribution(item_type = "all") ⇒ Hash

Gets the counts for each SRS level and item types.

Parameters:

  • item_type (String) (defaults to: "all")

    the SRS level that will be returned.

Returns:

  • (Hash)

    Returns the SRS information for each level for the user.

Raises:

  • (ArgumentError)


10
11
12
13
14
15
16
17
18
# File 'lib/wanikani/srs.rb', line 10

def self.distribution(item_type = "all")
  raise ArgumentError, "Please use a valid SRS type (or none for all types)" if !ITEM_TYPES.include?(item_type)

  api_response = Wanikani.api_response("srs-distribution")
  srs_distribution = api_response["requested_information"]

  return srs_distribution if item_type == "all"
  return srs_distribution[item_type]
end