Class: Sightstone::ChampionModule
- Inherits:
-
SightstoneBaseModule
- Object
- SightstoneBaseModule
- Sightstone::ChampionModule
- Defined in:
- lib/sightstone/modules/champion_module.rb
Overview
Module to provide calls to the summoner api
Instance Method Summary collapse
-
#champions(optional = {}) ⇒ Array<Champion>
call to get champions.
-
#initialize(sightstone) ⇒ ChampionModule
constructor
A new instance of ChampionModule.
Constructor Details
#initialize(sightstone) ⇒ ChampionModule
Returns a new instance of ChampionModule.
7 8 9 |
# File 'lib/sightstone/modules/champion_module.rb', line 7 def initialize(sightstone) @sightstone = sightstone end |
Instance Method Details
#champions(optional = {}) ⇒ Array<Champion>
call to get champions
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sightstone/modules/champion_module.rb', line 14 def champions(optional={}) region = optional[:region] || @sightstone.region free_to_play = optional[:free_to_play] uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.1/champion" response = _get_api_response(uri, {'freeToPlay' => free_to_play}) _parse_response(response) { |resp| data = JSON.parse(resp) champions = [] data['champions'].each do |champ| champions << Champion.new(champ) end if block_given? yield champions else return champions end } end |