Class: Strife::Client

Inherits:
Object
  • Object
show all
Includes:
Champion, Game, League, Stats, Summoner, Team, Configurable
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

Summoner::VERSION

Constants included from Champion

Champion::VERSION

Instance Attribute Summary

Attributes included from Configurable

#api_endpoint, #api_key, #region

Instance Method Summary collapse

Methods included from Team

#team_by_summoner_id

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

#league_by_summoner

Methods included from Game

#recent_games_by_summoner

Methods included from Champion

#champion

Methods included from Configurable

#configure, keys, #reset!

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(options = {})
  Strife::Configurable.keys.each do |key|
    instance_variable_set(:"@#{key}", options[key] || Strife.instance_variable_get(:"@#{key}"))
  end
end

Instance Method Details

#agentObject



47
48
49
50
51
52
# File 'lib/strife/client.rb', line 47

def agent
  @agent ||= Sawyer::Agent.new("#{@api_endpoint}#{@region}/", sawyer_options) 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, options = {})
  request :get, url, options
end

#inspectObject

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_responseObject



43
44
45
# File 'lib/strife/client.rb', line 43

def last_response
  @last_response
end

#same_options?(opts) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/strife/client.rb', line 26

def same_options?(opts)
  opts.hash == options.hash
end