class LoLBase::Stats

Public Class Methods

new(summoner, connection) click to toggle source

Input

  • summoner - A Summoner object

  • connection - Current connection to Riot's API

Output: Returns a Stats object for further chaining

# File lib/lolbase/data/stats.rb, line 10
def initialize(summoner, connection)
  @summoner = summoner
  @connection = connection
  self
end

Public Instance Methods

ranked(season = LoLBase.config.current_season) click to toggle source
# File lib/lolbase/data/stats.rb, line 20
def ranked(season = LoLBase.config.current_season)
  fetch_stats(:ranked, season)
end
summary(season = LoLBase.config.current_season) click to toggle source
# File lib/lolbase/data/stats.rb, line 16
def summary(season = LoLBase.config.current_season)
  fetch_stats(:summary, season)
end

Private Instance Methods

fetch_stats(type, season) click to toggle source
# File lib/lolbase/data/stats.rb, line 26
def fetch_stats(type, season)
  response = @connection.get(
    "/api/lol/#{@summoner.region}/v#{LoLBase.config.version_stats}/stats/by-summoner/#{@summoner.id}/#{type}",
    { query: { season: "SEASON#{season}" } }
  )

  if type == :summary
    return SummaryStats.new response
  elsif type == :ranked
    return RankedStats.new response
  end
end