Class: Wanikani::SRS
- Inherits:
-
Object
- Object
- Wanikani::SRS
- Defined in:
- lib/wanikani/srs.rb
Constant Summary collapse
- ITEM_TYPES =
%w(apprentice guru master enlighten burned all)
Class Method Summary collapse
-
.distribution(item_type = "all") ⇒ Hash
Gets the counts for each SRS level and item types.
-
.full_response ⇒ Hash
Gets the full response of the SRS Distribution API call.
-
.items_by_type(item_type) ⇒ Array
Gets all items for a specific SRS level.
Class Method Details
.distribution(item_type = "all") ⇒ Hash
Gets the counts for each SRS level and item types.
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 |
.full_response ⇒ Hash
Gets the full response of the SRS Distribution API call.
42 43 44 |
# File 'lib/wanikani/srs.rb', line 42 def self.full_response return Wanikani.api_response("srs-distribution") end |
.items_by_type(item_type) ⇒ Array
Gets all items for a specific SRS level.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/wanikani/srs.rb', line 24 def self.items_by_type(item_type) raise ArgumentError, "Please use a valid SRS type." if !ITEM_TYPES.include?(item_type) || item_type == "all" items_by_type = [] %w(radicals kanji vocabulary).each do |type| items = Wanikani::Level.send(type) items.reject! { |item| item["user_specific"].nil? || item["user_specific"]["srs"] != item_type }.map! do |item| item.merge!("type" => (type == 'radicals' ? 'radical' : type)) end items_by_type << items end items_by_type.flatten end |