Class: Lol::Client
- Inherits:
-
Object
- Object
- Lol::Client
- Defined in:
- lib/lol/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ String
readonly
The API key that has been used.
-
#region ⇒ String
Name of region.
-
#ttl ⇒ Fixnum
readonly
The ttl on cached requests.
Instance Method Summary collapse
-
#cache_store ⇒ Hash
Returns an options hash with cache keys.
-
#cached? ⇒ Boolean
True if requests are cached.
- #champion ⇒ ChampionRequest
- #current_game ⇒ CurrentGameRequest
- #featured_games ⇒ FeaturedGamesRequest
- #game ⇒ GameRequest
-
#initialize(api_key, options = {}) ⇒ Lol::Client
constructor
Initializes a Lol::Client.
- #league ⇒ LeagueRequest
- #lol_status ⇒ LolStatusRequest
- #match ⇒ MatchRequest
-
#redis ⇒ Redis
The cache store (if available).
- #set_up_cache(redis_url, ttl) ⇒ Object
- #static ⇒ StaticRequest
- #stats ⇒ StatsRequest
- #summoner ⇒ SummonerRequest
- #team ⇒ TeamRequest
Constructor Details
#initialize(api_key, options = {}) ⇒ Lol::Client
Initializes a Lol::Client
78 79 80 81 82 |
# File 'lib/lol/client.rb', line 78 def initialize api_key, = {} @api_key = api_key @region = .delete(:region) || "euw" set_up_cache(.delete(:redis), .delete(:ttl)) end |
Instance Attribute Details
#api_key ⇒ String (readonly)
Returns the API key that has been used.
10 11 12 |
# File 'lib/lol/client.rb', line 10 def api_key @api_key end |
#region ⇒ String
Returns name of region.
6 7 8 |
# File 'lib/lol/client.rb', line 6 def region @region end |
#ttl ⇒ Fixnum (readonly)
Returns the ttl on cached requests.
14 15 16 |
# File 'lib/lol/client.rb', line 14 def ttl @ttl end |
Instance Method Details
#cache_store ⇒ Hash
Returns an options hash with cache keys
94 95 96 97 98 99 100 |
# File 'lib/lol/client.rb', line 94 def cache_store { redis: @redis, ttl: @ttl, cached: @cached, } end |
#cached? ⇒ Boolean
Returns true if requests are cached.
103 104 105 |
# File 'lib/lol/client.rb', line 103 def cached? @cached end |
#champion ⇒ ChampionRequest
17 18 19 |
# File 'lib/lol/client.rb', line 17 def champion @champion_request ||= ChampionRequest.new(api_key, region, cache_store) end |
#current_game ⇒ CurrentGameRequest
62 63 64 |
# File 'lib/lol/client.rb', line 62 def current_game @current_game ||= CurrentGameRequest.new(api_key, region, cache_store) end |
#featured_games ⇒ FeaturedGamesRequest
67 68 69 |
# File 'lib/lol/client.rb', line 67 def featured_games @featured_games ||= FeaturedGamesRequest.new(api_key, region, cache_store) end |
#game ⇒ GameRequest
22 23 24 |
# File 'lib/lol/client.rb', line 22 def game @game_request ||= GameRequest.new(api_key, region, cache_store) end |
#league ⇒ LeagueRequest
37 38 39 |
# File 'lib/lol/client.rb', line 37 def league @league_request ||= LeagueRequest.new(api_key, region, cache_store) end |
#lol_status ⇒ LolStatusRequest
57 58 59 |
# File 'lib/lol/client.rb', line 57 def lol_status @lol_status ||= LolStatusRequest.new(region, cache_store) end |
#match ⇒ MatchRequest
27 28 29 |
# File 'lib/lol/client.rb', line 27 def match @match_request ||= MatchRequest.new(api_key, region, cache_store) end |
#redis ⇒ Redis
Returns the cache store (if available).
108 109 110 |
# File 'lib/lol/client.rb', line 108 def redis @redis end |
#set_up_cache(redis_url, ttl) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/lol/client.rb', line 84 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 |
#static ⇒ StaticRequest
52 53 54 |
# File 'lib/lol/client.rb', line 52 def static @static_request ||= StaticRequest.new(api_key, region, cache_store) end |
#stats ⇒ StatsRequest
32 33 34 |
# File 'lib/lol/client.rb', line 32 def stats @stats_request ||= StatsRequest.new(api_key, region, cache_store) end |
#summoner ⇒ SummonerRequest
47 48 49 |
# File 'lib/lol/client.rb', line 47 def summoner @summoner_request ||= SummonerRequest.new(api_key, region, cache_store) end |
#team ⇒ TeamRequest
42 43 44 |
# File 'lib/lol/client.rb', line 42 def team @team_request ||= TeamRequest.new(api_key, region, cache_store) end |