class Starcall::StaticData
This class is used for all things Static Data related. Using Riots Static data and Data Dragon.
Attributes
Public Class Methods
Initialize the class with a region, if none is supplied, EUW will be assumed.
# File lib/starcall/static_data.rb, line 10 def initialize(region: 'euw', language: 'en_GB') Starcall::Regions.valid?(region: region) Starcall::Languages.valid?(language: language) @region = region @language = language end
Public Instance Methods
This returns a list of all champion with a brief summary, including stats, id and blurb.
# File lib/starcall/static_data.rb, line 61 def dd_champions Starcall::ApiRequests.make_request(url: dd_url(game_component: 'champion')) end
Data Dragon also provides detail for every item in the game. with this method you can find info such as the item's description, purchase value, sell value, items it builds from, items it builds into, and stats granted from the item.
# File lib/starcall/static_data.rb, line 73 def dd_items Starcall::ApiRequests.make_request(url: dd_url(game_component: 'item')) end
Details about profile icons and where they can be found on the sprite sheets.
# File lib/starcall/static_data.rb, line 83 def dd_profile_icons Starcall::ApiRequests.make_request(url: dd_url(game_component: 'profileicon')) end
Data Dragon versions aren't always equivalent to the League of Legends client version in a region.
# File lib/starcall/static_data.rb, line 56 def dd_region_versions Starcall::ApiRequests.make_request(url: dd_region_version_url) end
For me detailed and specific information about a champion, this call can be used.
# File lib/starcall/static_data.rb, line 66 def dd_specific_champion(champion_name:) Starcall::ApiRequests.make_request(url: dd_specific_champion_url(champion_name: champion_name)) end
Details about summoner spells.
# File lib/starcall/static_data.rb, line 78 def dd_summoner_spells Starcall::ApiRequests.make_request(url: dd_url(game_component: 'summoner')) end
All valid Data Dragon versions can be can be retrieved with the below method. Typically there's only a single build of Data Dragon for a given patch, however occasionally there will be additional builds. This typically occurs when there's an error in the original build. As such, you should always use the most recent Data Dragon version for a given patch for the best results.
# File lib/starcall/static_data.rb, line 51 def dd_versions Starcall::ApiRequests.make_request(url: dd_versions_url) end
A full list of game modes can be can be retrieved with the below method.
# File lib/starcall/static_data.rb, line 37 def game_modes Starcall::ApiRequests.make_request(url: static_url(search_term: 'gameModes')) end
A full list of game types can be can be retrieved with the below method.
# File lib/starcall/static_data.rb, line 42 def game_types Starcall::ApiRequests.make_request(url: static_url(search_term: 'gameTypes')) end
Map ids are used in match history to indicate which map a match was played. A full list of map ids can be can be retrieved with the below method.
# File lib/starcall/static_data.rb, line 32 def map_ids Starcall::ApiRequests.make_request(url: static_url(search_term: 'maps')) end
Queue ids show up in several places throughout the API and are used to indicate which kind of match was played. A full list of queue ids can be can be retrieved with the below method.
# File lib/starcall/static_data.rb, line 26 def queue_ids Starcall::ApiRequests.make_request(url: static_url(search_term: 'queues')) end
Season ids are used in match history to indicate which season a match was played. A full list of season ids can be retrieved with the below method.
# File lib/starcall/static_data.rb, line 20 def season_ids Starcall::ApiRequests.make_request(url: static_url(search_term: 'seasons')) end
Private Instance Methods
This gets the current version of specific game components, such as champions.
# File lib/starcall/static_data.rb, line 107 def dd_current_data_version(game_component:) Starcall::ApiRequests.make_request(url: dd_region_version_url)['n'][game_component] end
This is the specific EUW data dragon version URL.
# File lib/starcall/static_data.rb, line 102 def dd_region_version_url "https://ddragon.leagueoflegends.com/realms/#{region}.json" end
This builds the data dragon url for a specific champion.
# File lib/starcall/static_data.rb, line 120 def dd_specific_champion_url(champion_name:) 'http://ddragon.leagueoflegends.com/cdn/'\ "#{dd_current_data_version(game_component: 'champion')}"\ "/data/#{language}/champion/#{champion_name}.json" end
This builds the data dragon url for specific components such as champions, using the above method to get the version.
# File lib/starcall/static_data.rb, line 113 def dd_url(game_component:) 'http://ddragon.leagueoflegends.com/cdn/'\ "#{dd_current_data_version(game_component: game_component)}/data/#{language}/"\ "#{game_component}.json" end
This is the data dragon version URL
# File lib/starcall/static_data.rb, line 97 def dd_versions_url 'https://ddragon.leagueoflegends.com/api/versions.json' end
This help build the static data url for thins such as map ids.
# File lib/starcall/static_data.rb, line 92 def static_url(search_term:) "http://static.developer.riotgames.com/docs/lol/#{search_term}.json" end