Class: LeagueModule
- Inherits:
-
SightstoneBaseModule
- Object
- SightstoneBaseModule
- LeagueModule
- Defined in:
- lib/sightstone/modules/league_module.rb
Instance Method Summary collapse
-
#initialize(sightstone) ⇒ LeagueModule
constructor
A new instance of LeagueModule.
- #league(summoner, optional = {}) ⇒ Object
Constructor Details
#initialize(sightstone) ⇒ LeagueModule
Returns a new instance of LeagueModule.
6 7 8 |
# File 'lib/sightstone/modules/league_module.rb', line 6 def initialize(sightstone) @sightstone = sightstone end |
Instance Method Details
#league(summoner, optional = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sightstone/modules/league_module.rb', line 10 def league(summoner, optional={}) region = optional[:region] || @sightstone.region id = if summoner.is_a? Summoner summoner.id else summoner end uri = "https://prod.api.pvp.net/api/#{region}/v2.1/league/by-summoner/#{id}" response = _get_api_response(uri) _parse_response(response) { |resp| data = JSON.parse(resp) leagueKeys = data.keys leagues = [] leagueKeys.each do |key| leagues << League.new(data[key]) end return leagues } end |