class RiotAPI::Summoner

Attributes

region[RW]

Public Class Methods

find(region, summoner_id) click to toggle source

Find a summoner by it’s summoner ID

# File lib/riot_api/summoner.rb, line 24
def self.find(region, summoner_id) 
        response = RiotAPI::Client.get(region, "summoner/#{summoner_id}")
        if response
                Summoner.new(response)
        else
                nil
        end
end
find_by_name(region, name) click to toggle source

Find a summoner by it’s name

# File lib/riot_api/summoner.rb, line 14
def self.find_by_name(region, name) 
        response = RiotAPI::Client.get(region, "summoner/by-name/#{name}")
        if response
                Summoner.new(response, region)
        else
                nil
        end
end
names_by_ids(region, summoner_ids) click to toggle source

Returns an array of names. summoner_ids should be an array of summoner_ids

# File lib/riot_api/summoner.rb, line 34
def self.names_by_ids(region, summoner_ids)
        summoner_ids = summoner_ids.join(',').first(40).compact
        response = RiotAPI::Client.get(region, "summoner/#{summoner_ids}/name")
        response || []
end
new(data, region) click to toggle source
# File lib/riot_api/summoner.rb, line 4
def initialize(data, region)
        @region = region
        data.each do |key, value|
                key = key.underscore
                self.class.send(:attr_accessor, key.to_sym)
                instance_variable_set("@#{key}", value)
        end
end

Public Instance Methods

mastery_pages() click to toggle source

Returns the MasteryPage array for the Summoner instance

# File lib/riot_api/summoner.rb, line 41
def mastery_pages
        MasteryPage.find(self.region, self.id)
end
player_stats(season='SEASON3') click to toggle source

Returns the Player Stats for the Summoner

# File lib/riot_api/summoner.rb, line 51
def player_stats(season='SEASON3')
        PlayerStatSummary.find(self.region, self.id, season)
end
recent_games() click to toggle source

Returns the last 10 games for the Summoner

# File lib/riot_api/summoner.rb, line 56
def recent_games
        Game.recent_games(self.region, self.id)
end
rune_pages() click to toggle source

Returns the RunePage array for the Summoner instance

# File lib/riot_api/summoner.rb, line 46
def rune_pages
        RunePage.find(self.region, self.id)
end