Class: LoLBase::Stats

Inherits:
Object
  • Object
show all
Defined in:
lib/lolbase/data/stats.rb

Instance Method Summary collapse

Constructor Details

#initialize(summoner, connection) ⇒ Stats

Input

  • summoner - A Summoner object

  • connection - Current connection to Riot’s API

Output: Returns a Stats object for further chaining



10
11
12
13
14
# File 'lib/lolbase/data/stats.rb', line 10

def initialize(summoner, connection)
  @summoner = summoner
  @connection = connection
  self
end

Instance Method Details

#ranked(season = LoLBase.config.current_season) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/lolbase/data/stats.rb', line 24

def ranked(season = LoLBase.config.current_season)
  response = @connection.get(
    "/api/lol/#{@summoner.region}/v#{LoLBase.config.version_stats}/stats/by-summoner/#{@summoner.id}/ranked",
    { query: { season: "SEASON#{season}" } }
  )
  RankedStats.new response
end

#summary(season = LoLBase.config.current_season) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/lolbase/data/stats.rb', line 16

def summary(season = LoLBase.config.current_season)
  response = @connection.get(
    "/api/lol/#{@summoner.region}/v#{LoLBase.config.version_stats}/stats/by-summoner/#{@summoner.id}/summary",
    { query: { season: "SEASON#{season}" } }
  )
  SummaryStats.new response
end