Class: RitoApi::Requests::Summoner
- Inherits:
-
Basic
- Object
- Basic
- RitoApi::Requests::Summoner
show all
- Defined in:
- lib/rito_api/requests/summoner.rb
Instance Method Summary
collapse
-
#champion_mastery(ign, count = 0, ttl = @ttl) ⇒ Object
-
#find(ign, ttl = @ttl) ⇒ Object
Finds summoner using the summonerName.
-
#find_by_accountID(id, ttl = @ttl) ⇒ Object
Finds summoner using accountID.
-
#find_by_summonerID(id, ttl = @ttl) ⇒ Object
Finds summoner using summonerID.
-
#flex(ign, ttl = @ttl) ⇒ Object
-
#icon(iconId) ⇒ Object
-
#rank_info(ign, ttl = @ttl) ⇒ Object
-
#recent_matches(ign, ttl = @ttl) ⇒ Object
-
#solo(ign, ttl = @ttl) ⇒ Object
-
#top_positions(ign, ttl = @ttl) ⇒ Object
-
#tt(ign, ttl = @ttl) ⇒ Object
Methods inherited from Basic
#base_url, #cached?, #clean_url, #initialize, #leagueVer, #make_request, #region_tag, #request_url, #symbolize
Instance Method Details
#champion_mastery(ign, count = 0, ttl = @ttl) ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/rito_api/requests/summoner.rb', line 80
def champion_mastery(ign, count = 0, ttl= @ttl)
unless ign.is_a?Numeric
mastery = make_request(request_url("lol/champion-mastery/v3/champion-masteries/by-summoner/#{find(ign)[:id]}"), ttl)
else
mastery = make_request(request_url("lol/champion-mastery/v3/champion-masteries/by-summoner/#{ign}"), ttl)
end
topChamps=[]
if count.to_i <= 0 or count.to_i >= mastery.size
return mastery
else
(0...count.to_i).each{|x| topChamps.push(mastery[x])}
return topChamps
end
end
|
#find(ign, ttl = @ttl) ⇒ Object
Finds summoner using the summonerName.
7
8
9
|
# File 'lib/rito_api/requests/summoner.rb', line 7
def find(ign, ttl = @ttl) return make_request(request_url("lol/summoner/v3/summoners/by-name/#{ign}"), ttl)
end
|
#find_by_accountID(id, ttl = @ttl) ⇒ Object
Finds summoner using accountID. [Don’t use unless absolutely necessary]
15
16
17
|
# File 'lib/rito_api/requests/summoner.rb', line 15
def find_by_accountID(id, ttl = @ttl) return make_request(request_url("lol/summoner/v3/summoners/by-account/#{id}"), ttl)
end
|
#find_by_summonerID(id, ttl = @ttl) ⇒ Object
Finds summoner using summonerID. [Not encouraged method to be used, unless under the hood.]
11
12
13
|
# File 'lib/rito_api/requests/summoner.rb', line 11
def find_by_summonerID(id, ttl = @ttl) return make_request(request_url("lol/summoner/v3/summoners/#{id}"), ttl)
end
|
#flex(ign, ttl = @ttl) ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/rito_api/requests/summoner.rb', line 37
def flex(ign, ttl = @ttl)
rank = {}
rank_info(ign,ttl).each do |r|
if r[:queueType] == 'RANKED_FLEX_SR'
rank = r
end
end
return rank
end
|
#icon(iconId) ⇒ Object
75
76
77
78
|
# File 'lib/rito_api/requests/summoner.rb', line 75
def icon(iconId)
icon = "https://ddragon.leagueoflegends.com/cdn/#{leagueVer}/img/profileicon/#{iconId.to_i}.png"
return icon
end
|
#rank_info(ign, ttl = @ttl) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/rito_api/requests/summoner.rb', line 19
def rank_info(ign, ttl = @ttl)
unless ign.is_a?Numeric
return make_request(request_url("lol/league/v3/positions/by-summoner/#{find(ign)[:id]}"), ttl)
else
return make_request(request_url("lol/league/v3/positions/by-summoner/#{ign}"), ttl)
end
end
|
#recent_matches(ign, ttl = @ttl) ⇒ Object
57
58
59
|
# File 'lib/rito_api/requests/summoner.rb', line 57
def recent_matches(ign, ttl = @ttl)
return make_request(request_url("lol/match/v3/matchlists/by-account/#{find(ign)[:accountId]}/recent"), ttl)
end
|
#solo(ign, ttl = @ttl) ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'lib/rito_api/requests/summoner.rb', line 27
def solo(ign, ttl = @ttl)
rank = {}
rank_info(ign,ttl).each do |r|
if r[:queueType] == 'RANKED_SOLO_5x5'
rank = r
end
end
return rank
end
|
#top_positions(ign, ttl = @ttl) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/rito_api/requests/summoner.rb', line 61
def top_positions(ign, ttl = @ttl)
positions=[]
recent_matches(ign, ttl)[:matches].each do |x|
if x[:lane] == 'BOTTOM'
positions.push(x[:role])
else
positions.push(x[:lane])
end
end
positions = Hash[positions.group_by(&:itself).map {|k,v| [k, v.size] }]
return (positions.sort_by{|k,v|v}.reverse.map{|k,v| k}).values_at(0,1)
end
|
#tt(ign, ttl = @ttl) ⇒ Object
47
48
49
50
51
52
53
54
55
|
# File 'lib/rito_api/requests/summoner.rb', line 47
def tt(ign, ttl = @ttl)
rank = {}
rank_info(ign,ttl).each do |r|
if r[:queueType] == 'RANKED_FLEX_TT'
rank = r
end
end
return rank
end
|