Class: Vigor
- Inherits:
-
Object
show all
- Defined in:
- lib/vigor.rb,
lib/vigor/game.rb,
lib/vigor/page.rb,
lib/vigor/rune.rb,
lib/vigor/team.rb,
lib/vigor/error.rb,
lib/vigor/stats.rb,
lib/vigor/client.rb,
lib/vigor/league.rb,
lib/vigor/talent.rb,
lib/vigor/champion.rb,
lib/vigor/summoner.rb,
lib/vigor/rune_page.rb,
lib/vigor/mastery_page.rb,
lib/vigor/champion_stats.rb
Defined Under Namespace
Classes: Champion, ChampionSet, ChampionStats, Client, Error, Game, League, LeagueMember, MasteryPage, Page, Rune, RunePage, Series, Stats, StatsSet, Summoner, Talent, Team, TeamGame, TeamStat
Class Method Summary
collapse
Class Method Details
.all_champions(refresh = false) ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/vigor.rb', line 50
def all_champions(refresh=false)
if refresh
@@champions = Client.get("/v1.1/champion")["champions"].map {|champ| Champion.new(champ)}
else
@@champions ||= Client.get("/v1.1/champion")["champions"].map {|champ| Champion.new(champ)}
end
end
|
.champion(lookup_value) ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/vigor.rb', line 62
def champion(lookup_value)
if lookup_value.is_a? String
self.all_champions.find {|champ| champ.name == lookup_value}
else
self.all_champions.find {|champ| champ.id == lookup_value}
end
end
|
.champion_stats(id, season = nil) ⇒ Object
returns detailed ranked stats for each champion (combines rift and treeline stats)
85
86
87
|
# File 'lib/vigor.rb', line 85
def champion_stats(id, season = nil)
ChampionStats.new(Client.get("/v1.2/stats/by-summoner/#{id}/ranked", query: {"season" => season.to_s}))
end
|
21
22
23
24
25
26
27
|
# File 'lib/vigor.rb', line 21
def configure(api_key, region = "na")
region.downcase!
raise Vigor::Error::InvalidRegion, "Invalid Region Configuration" unless ['na', 'euw', 'eune', 'br', 'tr'].include?(region)
Client.default_params :api_key => api_key
Client.base_uri "http://prod.api.pvp.net/api/lol/#{region}"
self
end
|
.free_to_play ⇒ Object
58
59
60
|
# File 'lib/vigor.rb', line 58
def free_to_play
Client.get("/v1.1/champion/", query: {"freeToPlay" => true})["champions"].map {|champ| Champion.new(champ)}
end
|
.leagues(id) ⇒ Object
89
90
91
|
# File 'lib/vigor.rb', line 89
def leagues(id)
Client.get("/v2.2/league/by-summoner/#{id}").map { |id, league| League.new(league, id) }
end
|
.mastery_pages(id) ⇒ Object
42
43
44
|
# File 'lib/vigor.rb', line 42
def mastery_pages(id)
Client.get("/v1.2/summoner/#{id.to_s}/masteries")["pages"].map {|page| MasteryPage.new(page)}
end
|
.recent_games(id) ⇒ Object
70
71
72
73
|
# File 'lib/vigor.rb', line 70
def recent_games(id)
games = Client.get("/v1.2/game/by-summoner/#{id.to_s}/recent")["games"].map {|game| Game.new(game)}
games.sort { |x, y| y.created_at <=> x.created_at }
end
|
.rune_pages(id) ⇒ Object
46
47
48
|
# File 'lib/vigor.rb', line 46
def rune_pages(id)
Client.get("/v1.2/summoner/#{id.to_s}/runes")["pages"].map {|page| RunePage.new(page)}
end
|
.stats(id, season = nil) ⇒ Object
returns summary stats for each queue type
80
81
82
|
# File 'lib/vigor.rb', line 80
def stats(id, season = nil)
Stats.new(Client.get("/v1.2/stats/by-summoner/#{id}/summary", query: {"season" => season.to_s}))
end
|
.summoner(lookup_value) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/vigor.rb', line 29
def summoner(lookup_value)
if lookup_value.is_a? String
return Summoner.new(Client.get("/v1.2/summoner/by-name/" + lookup_value.gsub(/\s+/, "")))
else
return Summoner.new(Client.get("/v1.2/summoner/" + lookup_value.to_s))
end
end
|
.summoners(ids) ⇒ Object
37
38
39
40
|
# File 'lib/vigor.rb', line 37
def summoners(ids)
response = Client.get("/v1.2/summoner/#{URI.encode(ids.join(", "))}/name")
response["summoners"].map { |summoner| Summoner.new(summoner, :name_and_id) }
end
|
.teams(id) ⇒ Object
75
76
77
|
# File 'lib/vigor.rb', line 75
def teams(id)
Client.get("/v2.2/team/by-summoner/#{id.to_s}").map {|team| Team.new(team)}
end
|