class Lol::Client

Attributes

api_key[R]

@!attribute [r] api_key @return [String] the API key that has been used

rate_limiter[R]

@!attribute rate_limiter @return [Object] the rate limiter, if one exists (else nil)

region[RW]

@!attribute [rw] region @return [String] name of region

ttl[R]

@!attribute [r] ttl @return [Integer] the ttl on cached requests

Public Class Methods

new(api_key, options = {}) click to toggle source

Initializes a Lol::Client @param api_key [String] @param options [Hash] @option options [String] :region (“EUW”) The region on which the requests will be made @option options [String] :redis the redis url to use for caching @option options [Integer] :ttl (900) the cache ttl @option options [Fixnum] :rate_limit_requests number of requests @option options [Fixnum] :rate_limit_seconds number of seconds to limit the rate in @return [Lol::Client]

# File lib/lol/client.rb, line 94
def initialize api_key, options = {}
  @api_key = api_key
  @region = options.delete(:region) || "euw"
  set_up_cache(options.delete(:redis), options.delete(:ttl))
  set_up_rate_limiter(options.delete(:rate_limit_requests), options.delete(:rate_limit_seconds))
end

Public Instance Methods

cache_store() click to toggle source

Returns an options hash with cache keys @return [Hash]

# File lib/lol/client.rb, line 118
def cache_store
  {
    redis:  @redis,
    ttl:    @ttl,
    cached: @cached,
  }
end
cached?() click to toggle source

@return [Boolean] true if requests are cached

# File lib/lol/client.rb, line 132
def cached?
  @cached
end
champion() click to toggle source

@return [ChampionRequest]

# File lib/lol/client.rb, line 21
def champion
  @champion_request ||= ChampionRequest.new(api_key, region, cache_store, rate_limiter)
end
champion_mastery() click to toggle source

@return [ChampionMasteryRequest]

# File lib/lol/client.rb, line 26
def champion_mastery
  @champion_mastery_request ||= ChampionMasteryRequest.new(api_key, region, cache_store, rate_limiter)
end
current_game() click to toggle source

@return [CurrentGameRequest]

# File lib/lol/client.rb, line 71
def current_game
  @current_game ||= CurrentGameRequest.new(api_key, region, cache_store, rate_limiter)
end
league() click to toggle source

@return [LeagueRequest]

# File lib/lol/client.rb, line 36
def league
  @league_request ||= LeagueRequest.new(api_key, region, cache_store, rate_limiter)
end
lol_status() click to toggle source

@return [LolStatusRequest]

# File lib/lol/client.rb, line 66
def lol_status
  @lol_status ||= LolStatusRequest.new(api_key, region, cache_store, rate_limiter)
end
masteries() click to toggle source

@return [MasteriesRequest]

# File lib/lol/client.rb, line 46
def masteries
  @masteries_request ||= MasteriesRequest.new(api_key, region, cache_store, rate_limiter)
end
match() click to toggle source

@return [MatchRequest]

# File lib/lol/client.rb, line 31
def match
  @match_request ||= MatchRequest.new(api_key, region, cache_store, rate_limiter)
end
rate_limited?() click to toggle source

@return [Boolean] true if requests are automatically rate limited

# File lib/lol/client.rb, line 127
def rate_limited?
  @rate_limiter
end
redis() click to toggle source

@return [Redis] the cache store (if available)

# File lib/lol/client.rb, line 137
def redis
  @redis
end
runes() click to toggle source

@return [RunesRequest]

# File lib/lol/client.rb, line 41
def runes
  @runes_request ||= RunesRequest.new(api_key, region, cache_store, rate_limiter)
end
set_up_cache(redis_url, ttl) click to toggle source
# File lib/lol/client.rb, line 101
def set_up_cache(redis_url, ttl)
  return @cached = false unless redis_url

  @ttl = ttl || 900
  @cached = true
  @redis = Redis.new :url => redis_url
end
set_up_rate_limiter(number_of_requests, number_of_seconds) click to toggle source
# File lib/lol/client.rb, line 109
def set_up_rate_limiter(number_of_requests, number_of_seconds)
  return @rate_limited = false unless number_of_requests

  @rate_limited = true
  @rate_limiter = GluttonRatelimit::AveragedThrottle.new number_of_requests, number_of_seconds
end
spectator() click to toggle source

@return [SpectatorRequest]

# File lib/lol/client.rb, line 51
def spectator
  @spectator_request ||= SpectatorRequest.new(api_key, region, cache_store, rate_limiter)
end
static() click to toggle source

@return [StaticRequest]

# File lib/lol/client.rb, line 61
def static
  @static_request ||= StaticRequest.new(api_key, region, cache_store, rate_limiter)
end
summoner() click to toggle source

@return [SummonerRequest]

# File lib/lol/client.rb, line 56
def summoner
  @summoner_request ||= SummonerRequest.new(api_key, region, cache_store, rate_limiter)
end
tournament() click to toggle source

@return [TournamentProviderRequest]

# File lib/lol/client.rb, line 81
def tournament
  @tournament ||= TournamentRequest.new(api_key, region, cache_store, rate_limiter)
end