Class: RiotKit::Services::DataDragon::FetchItems

Inherits:
Base
  • Object
show all
Defined in:
lib/riot_kit/services/data_dragon/fetch_items.rb

Constant Summary collapse

MYTHIC_ITEM_IDS =
[3152, 3190, 4644, 3068, 3001].freeze
MYTHIC_RANGE =
(6600..6699)
BOOT_ITEM_IDS =
[1001, 3006, 3009, 3047, 3111, 3117, 3158].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

call, #call, steps

Constructor Details

#initialize(item_id:, registry: Registries::DataDragon.current) ⇒ FetchItems

Returns a new instance of FetchItems.



17
18
19
20
# File 'lib/riot_kit/services/data_dragon/fetch_items.rb', line 17

def initialize(item_id:, registry: Registries::DataDragon.current)
  @item_id = item_id
  @registry = registry
end

Class Method Details

.categorize(item_ids, _registry: Registries::DataDragon.current) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/riot_kit/services/data_dragon/fetch_items.rb', line 22

def self.categorize(item_ids, _registry: Registries::DataDragon.current)
  categories = { mythic: [], boots: [], legendary: [] }
  Array(item_ids).each do |raw_id|
    next if raw_id.nil? || raw_id.to_i.zero?

    id = raw_id.to_i
    if MYTHIC_ITEM_IDS.include?(id) || MYTHIC_RANGE.cover?(id)
      categories[:mythic] << id
    elsif BOOT_ITEM_IDS.include?(id)
      categories[:boots] << id
    else
      categories[:legendary] << id
    end
  end
  categories
end