Class: Strife::Client
- Inherits:
-
Object
- Object
- Strife::Client
- Defined in:
- lib/strife/client.rb,
lib/strife/client/game.rb,
lib/strife/client/team.rb,
lib/strife/client/stats.rb,
lib/strife/client/league.rb,
lib/strife/client/champion.rb,
lib/strife/client/summoner.rb
Defined Under Namespace
Modules: Champion, Game, League, Stats, Summoner, Team
Constant Summary
Constants included from Summoner
Constants included from Champion
Instance Attribute Summary
Attributes included from Configurable
#api_endpoint, #api_key, #region
Instance Method Summary collapse
- #agent ⇒ Object
- #get(url, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#inspect ⇒ Object
Scrub out our api key from #inspect.
- #last_response ⇒ Object
- #same_options?(opts) ⇒ Boolean
Methods included from Team
Methods included from Summoner
#summoner_by_id, #summoner_by_name, #summoner_masteries, #summoner_names, #summoner_runes
Methods included from Stats
#ranked_stats_by_summoner, #summary_stats_by_summoner
Methods included from League
Methods included from Game
Methods included from Champion
Methods included from Configurable
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
20 21 22 23 24 |
# File 'lib/strife/client.rb', line 20 def initialize( = {}) Strife::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", [key] || Strife.instance_variable_get(:"@#{key}")) end end |
Instance Method Details
#agent ⇒ Object
47 48 49 50 51 52 |
# File 'lib/strife/client.rb', line 47 def agent @agent ||= Sawyer::Agent.new("#{@api_endpoint}#{@region}/", ) do |http| http.headers[:accept] = @default_media_type http.headers[:user_agent] = @user_agent end end |
#get(url, options = {}) ⇒ Object
39 40 41 |
# File 'lib/strife/client.rb', line 39 def get(url, = {}) request :get, url, end |
#inspect ⇒ Object
Scrub out our api key from #inspect
31 32 33 34 35 36 37 |
# File 'lib/strife/client.rb', line 31 def inspect inspected = super inspected = inspected.gsub! @api_key, '*' * @api_key.length inspected end |
#last_response ⇒ Object
43 44 45 |
# File 'lib/strife/client.rb', line 43 def last_response @last_response end |
#same_options?(opts) ⇒ Boolean
26 27 28 |
# File 'lib/strife/client.rb', line 26 def (opts) opts.hash == .hash end |