class Sightstone::TeamModule
module to make calls to the team api
Public Class Methods
new(sightstone)
click to toggle source
# File lib/sightstone/modules/team_module.rb, line 8 def initialize(sightstone) @sightstone = sightstone end
Public Instance Methods
teams(summoner, optional={}) { |teams| ... }
click to toggle source
call to receive all teams for a summoner @param [Summoner, Fixnum] summoner summoner object or id of a summoner @param optional [Hash] optional arguments: :region => replaces default region @ return [Array<Team>] An array containing all teams of the given summoner
# File lib/sightstone/modules/team_module.rb, line 16 def teams(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/lol/#{region}/v2.2/team/by-summoner/#{id}" response = _get_api_response(uri) _parse_response(response) { |resp| data = JSON.parse(resp) teams = [] data.each do |team| teams << Team.new(team) end if block_given? yield teams else return teams end } end