class BlizzardApi::Wow::PlayableClass

This class allows access to World of Warcraft playable classes

@see develop.battle.net/documentation/api-reference/world-of-warcraft-game-data-api

You can get an instance of this class using the default region as follows:

api_instance = BlizzardApi::Wow.playable_class

Public Instance Methods

complete(**options) click to toggle source

@!macro complete

@option options [Boolean] :classic If set to true, this method will call the classic version @option options [Boolean] :classic1x If set to true, this method will call the classic era version

# File lib/blizzard_api/wow/game_data/playable_class.rb, line 29
def complete(**options)
  index_data = index(**options)
  [].tap do |classes|
    index_data[:classes].each do |pclass|
      class_id = %r{playable-class/([0-9]+)}.match(pclass[:key].to_s)[1]
      class_data = get class_id, **options
      classes.push class_data
    end
  end
end
get(id, **options) click to toggle source

Return playable class data by its id

@param id [Integer] Playable class id

@!macro request_options @option options [Boolean] :classic If set to true, this method will call the classic version @option options [Boolean] :classic1x If set to true, this method will call the classic era version

@!macro response

# File lib/blizzard_api/wow/game_data/playable_class.rb, line 50
def get(id, **options)
  data = api_request "#{endpoint_uri}/#{id}", **default_options.merge(options)
  data[:icon] = get_class_icon data[:media], **options
  data
end
media(id, **options) click to toggle source

Fetch media for one of the playable classes listed by the {#index} using its id

@param id [Integer] Playable class id

@!macro request_options

@!macro response

# File lib/blizzard_api/wow/game_data/playable_class.rb, line 64
def media(id, **options)
  api_request "#{base_url(:media)}/playable-class/#{id}", **default_options.merge(options)
end
talent_slots(id, **options) click to toggle source

Returns the PvP talent slots data of a specific class

@param id [Integer] Class id to fetch talent data. One of the IDs returned by the {index} method @!macro request_options

@!macro response

# File lib/blizzard_api/wow/game_data/playable_class.rb, line 20
def talent_slots(id, **options)
  api_request "#{endpoint_uri}/#{id}/pvp-talent-slots", **default_options.merge(options)
end

Protected Instance Methods

endpoint_setup() click to toggle source
# File lib/blizzard_api/wow/game_data/playable_class.rb, line 70
def endpoint_setup
  @endpoint = 'playable-class'
  @namespace = :static
  @collection = 'classes'
  @ttl = CACHE_TRIMESTER
end
get_class_icon(media_url, **options) click to toggle source
# File lib/blizzard_api/wow/game_data/playable_class.rb, line 77
def get_class_icon(media_url, **options)
  return if options.include? :classic

  media_data = request media_url[:key][:href], **options
  %r{56/([a-z_]+).jpg}.match(media_data[:assets][0][:value].to_s)[1]
end