Class: Lol::StatsRequest

Inherits:
Request show all
Defined in:
lib/lol/stats_request.rb

Instance Attribute Summary

Attributes inherited from Request

#api_key, #cache_store, #region

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Request

#api_url, #cached?, #initialize, #perform_request, #store, #ttl

Constructor Details

This class inherits a constructor from Lol::Request

Class Method Details

.api_versionString

Returns the supported API Version

Returns:

  • (String)

    the supported api version



5
6
7
# File 'lib/lol/stats_request.rb', line 5

def self.api_version
  "v1.2"
end

Instance Method Details

#ranked(summoner_id, extra = {}) ⇒ RankedStatisticsSummary

Retrieves ranked statistics summary for the given summoner

Parameters:

  • summoner_id (String)

Returns:



26
27
28
29
30
31
32
# File 'lib/lol/stats_request.rb', line 26

def ranked summoner_id, extra = {}
  if extra.keys.select { |k| k.to_sym != :season }.any?
    raise ArgumentError, 'Only :season is allowed as extra parameter'
  end
  stats_api_path = "stats/by-summoner/#{summoner_id}/ranked"
  RankedStatisticsSummary.new perform_request api_url stats_api_path, extra
end

#summary(summoner_id, extra = {}) ⇒ Array

Retrieves player statistics summaries for the given summoner

Parameters:

  • summoner_id (String)

Returns:

  • (Array)

    an array of player statistics, one per queue type



12
13
14
15
16
17
18
19
20
# File 'lib/lol/stats_request.rb', line 12

def summary summoner_id, extra = {}
  if extra.keys.select { |k| k.to_sym != :season }.any?
    raise ArgumentError, 'Only :season is allowed as extra parameter'
  end
  stats_api_path = "stats/by-summoner/#{summoner_id}/summary"
  perform_request(api_url(stats_api_path, extra))['playerStatSummaries'].map do |player_stat_data|
    PlayerStatistic.new player_stat_data
  end
end