Class: RiotAPI::Summoner
- Inherits:
-
Object
- Object
- RiotAPI::Summoner
- Defined in:
- lib/riot_api/resources/summoner.rb
Instance Attribute Summary collapse
-
#account_id ⇒ Object
Encrypted account ID.
-
#id ⇒ Object
Encrypted summoner ID.
-
#name ⇒ Object
Summoner name.
-
#profile_icon_id ⇒ Object
ID of the summoner icon associated with the summoner.
-
#puuid ⇒ Object
Encrypted PUUID.
-
#region ⇒ Object
The summoner associated region, e.g.: +:br+, +:na+.
-
#revision_date ⇒ Object
Date summoner was last modified specified as epoch milliseconds.
-
#summoner_level ⇒ Object
Summoner level associated with the summoner.
Class Method Summary collapse
-
.find(options = {}) ⇒ RiotAPI::Summoner
Finds a summoner using the Riot Games API.
- .from_json(json) ⇒ Object
Instance Method Summary collapse
-
#masteries ⇒ Array<RiotAPI::ChampionMastery>
Returns a list of champion mastery for each champion.
Instance Attribute Details
#account_id ⇒ Object
Encrypted account ID. Max length 56 characters.
7 8 9 |
# File 'lib/riot_api/resources/summoner.rb', line 7 def account_id @account_id end |
#id ⇒ Object
Encrypted summoner ID. Max length 63 characters.
4 5 6 |
# File 'lib/riot_api/resources/summoner.rb', line 4 def id @id end |
#name ⇒ Object
Summoner name.
16 17 18 |
# File 'lib/riot_api/resources/summoner.rb', line 16 def name @name end |
#profile_icon_id ⇒ Object
ID of the summoner icon associated with the summoner.
10 11 12 |
# File 'lib/riot_api/resources/summoner.rb', line 10 def profile_icon_id @profile_icon_id end |
#puuid ⇒ Object
Encrypted PUUID. Exact length of 78 characters.
13 14 15 |
# File 'lib/riot_api/resources/summoner.rb', line 13 def puuid @puuid end |
#region ⇒ Object
The summoner associated region, e.g.: +:br+, +:na+
25 26 27 |
# File 'lib/riot_api/resources/summoner.rb', line 25 def region @region end |
#revision_date ⇒ Object
Date summoner was last modified specified as epoch milliseconds. The following events will update this timestamp: profile icon change, playing the tutorial or advanced tutorial, finishing a game, summoner name change
22 23 24 |
# File 'lib/riot_api/resources/summoner.rb', line 22 def revision_date @revision_date end |
#summoner_level ⇒ Object
Summoner level associated with the summoner.
19 20 21 |
# File 'lib/riot_api/resources/summoner.rb', line 19 def summoner_level @summoner_level end |
Class Method Details
.find(options = {}) ⇒ RiotAPI::Summoner
Finds a summoner using the Riot Games API.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/riot_api/resources/summoner.rb', line 37 def self.find( = {}) = [:region] accepted_filters = [:name, :id, :account_id, :puuid] unless ( - .keys).empty? raise ArgumentError, "A required parameter was not informed. The required paramaters are #{mandatory_options}" end request_path = ( if .key?(:name) "/lol/summoner/v4/summoners/by-name/#{options[:name]}" elsif .key?(:id) "/lol/summoner/v4/summoners/#{options[:id]}" elsif .key?(:account_id) "/lol/summoner/v4/summoners/by-account/#{options[:account_id]}" elsif .key?(:puuid) "/lol/summoner/v4/summoners/by-puuid/#{options[:puuid]}" else raise ArgumentError, "The informed filter is not accepted. The accepted filters are #{accepted_filters}" end ) response = RiotAPI.client.request(:get, request_path, [:region]) instance = self.from_json(response) instance.region = [:region] instance end |
.from_json(json) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/riot_api/resources/summoner.rb', line 65 def self.from_json(json) self.new.tap do |s| s.id = json["id"] s.account_id = json["account_id"] s.profile_icon_id = json["profile_icon_id"] s.puuid = json["puuid"] s.name = json["name"] s.summoner_level = json["summoner_level"] s.revision_date = json["revision_date"] end end |
Instance Method Details
#masteries ⇒ Array<RiotAPI::ChampionMastery>
Returns a list of champion mastery for each champion
79 80 81 |
# File 'lib/riot_api/resources/summoner.rb', line 79 def masteries ChampionMastery.where(region: self.region, summoner_id: self.id) end |