Class: RiotAPI::ChampionMastery

Inherits:
Object
  • Object
show all
Defined in:
lib/riot_api/resources/champion_mastery.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#champion_idObject

Champion ID for this entry.



13
14
15
# File 'lib/riot_api/resources/champion_mastery.rb', line 13

def champion_id
  @champion_id
end

#champion_levelObject

Champion level for specified player and champion combination.



7
8
9
# File 'lib/riot_api/resources/champion_mastery.rb', line 7

def champion_level
  @champion_level
end

#champion_pointsObject

Total number of champion points for this player and champion combination - they are used to determine championLevel.



10
11
12
# File 'lib/riot_api/resources/champion_mastery.rb', line 10

def champion_points
  @champion_points
end

#champion_points_since_last_levelObject

Number of points earned since current level has been achieved.



25
26
27
# File 'lib/riot_api/resources/champion_mastery.rb', line 25

def champion_points_since_last_level
  @champion_points_since_last_level
end

#champion_points_until_next_levelObject

Number of points needed to achieve next level. Zero if player reached maximum champion level for this champion.



16
17
18
# File 'lib/riot_api/resources/champion_mastery.rb', line 16

def champion_points_until_next_level
  @champion_points_until_next_level
end

#chest_grantedObject

Is chest granted for this champion or not in current season.



4
5
6
# File 'lib/riot_api/resources/champion_mastery.rb', line 4

def chest_granted
  @chest_granted
end

#last_play_timeObject

Last time this champion was played by this player - in Unix milliseconds time format.



19
20
21
# File 'lib/riot_api/resources/champion_mastery.rb', line 19

def last_play_time
  @last_play_time
end

#summoner_idObject

Summoner ID for this entry. (Encrypted)



28
29
30
# File 'lib/riot_api/resources/champion_mastery.rb', line 28

def summoner_id
  @summoner_id
end

#tokens_earnedObject

The token earned for this champion to levelup.



22
23
24
# File 'lib/riot_api/resources/champion_mastery.rb', line 22

def tokens_earned
  @tokens_earned
end

Class Method Details

.find(options = {}) ⇒ RiotAPI::ChampionMastery

Finds the summoner mastery for a specific champion.

Examples:

Find a summoner's mastery info with Irelia

RiotAPI::ChampionMastery.find(region: :br, summoner_id: summoner.id, champion_id: 23)

Parameters:

  • (defaults to: {})

    The options and filters to find the mastery info

Options Hash (options):

  • :region (String)

    The League of Legends region associated with the account (e.g. +:br+, +:na+, etc)

  • :summoner_id (String)

    The encrypted summoner ID

  • :champion_id (String)

    The champion ID

Returns:

  • The champion mastery info



38
39
40
41
42
43
44
45
46
47
# File 'lib/riot_api/resources/champion_mastery.rb', line 38

def self.find(options = {})
  mandatory_options = [:region, :summoner_id, :champion_id]
  unless (mandatory_options - options.keys).empty?
    raise ArgumentError, "A required parameter was not informed. The required paramaters are #{mandatory_options}"
  end

  request_url = "/lol/champion-mastery/v4/champion-masteries/by-summoner/#{options[:summoner_id]}/by-champion/#{options[:champion_id]}"
  response = RiotAPI.client.request(:get, request_url, options[:region])
  self.from_json(response)
end

.from_json(json) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/riot_api/resources/champion_mastery.rb', line 85

def self.from_json(json)
  self.new.tap do |s|
    s.chest_granted = json["chestGranted"]
    s.champion_level = json["championLevel"]
    s.champion_points = json["championPoints"]
    s.champion_id = json["championId"]
    s.champion_points_until_next_level = json["championPointsUntilNextLevel"]
    s.last_play_time = json["lastPlayTime"]
    s.tokens_earned = json["tokensEarned"]
    s.champion_points_since_last_level = json["championPointsSinceLastLevel"]
    s.summoner_id = json["summonerId"]
  end
end

.score_sum(options = {}) ⇒ Integer

Get a player's total champion mastery score, which is the sum of individual champion mastery levels.

Examples:

Find a summoner total champion mastery score

RiotAPI::ChampionMastery.point_sum(region: :br, summoner_id: summoner.id)

Parameters:

  • (defaults to: {})

    The options and filters to find the mastery points sum

Options Hash (options):

  • :region (String)

    The League of Legends region associated with the account (e.g. +:br+, +:na+, etc)

  • :summoner_id (String)

    The encrypted summoner ID

Returns:

  • The player's total champion mastery score



75
76
77
78
79
80
81
82
83
# File 'lib/riot_api/resources/champion_mastery.rb', line 75

def self.score_sum(options = {})
  mandatory_options = [:region, :summoner_id]
  unless (mandatory_options - options.keys).empty?
    raise ArgumentError, "A required parameter was not informed. The required paramaters are #{mandatory_options}"
  end

  request_url = "/lol/champion-mastery/v4/scores/by-summoner/#{options[:summoner_id]}"
  response = RiotAPI.client.request(:get, request_url, options[:region])
end

.where(options = {}) ⇒ Array<RiotAPI::ChampionMastery>

Finds all champion mastery information for a specific summoner.

Examples:

Find a summoner's list of champion mastery

RiotAPI::ChampionMastery.where(region: :br, summoner_id: summoner.id)

Parameters:

  • (defaults to: {})

    The options and filters to find the mastery info

Options Hash (options):

  • :region (String)

    The League of Legends region associated with the account (e.g. +:br+, +:na+, etc)

  • :summoner_id (String)

    The encrypted summoner ID

Returns:

  • A list of mastery info for each champion



56
57
58
59
60
61
62
63
64
65
# File 'lib/riot_api/resources/champion_mastery.rb', line 56

def self.where(options = {})
  mandatory_options = [:region, :summoner_id]
  unless (mandatory_options - options.keys).empty?
    raise ArgumentError, "A required parameter was not informed. The required paramaters are #{mandatory_options}"
  end

  request_url = "/lol/champion-mastery/v4/champion-masteries/by-summoner/#{options[:summoner_id]}"
  response = RiotAPI.client.request(:get, request_url, options[:region])
  response.map { |raw| self.from_json(raw) }
end