Class: ESPN::Client

Inherits:
Object
  • Object
show all
Includes:
Athletes, Audio, Headlines, Medals, Notes, Now, Scores, Sports, Standings, Teams, Video, Helpers, Request
Defined in:
lib/espn/client.rb,
lib/espn/client/now.rb,
lib/espn/client/audio.rb,
lib/espn/client/notes.rb,
lib/espn/client/teams.rb,
lib/espn/client/video.rb,
lib/espn/client/medals.rb,
lib/espn/client/scores.rb,
lib/espn/client/sports.rb,
lib/espn/client/athletes.rb,
lib/espn/client/headlines.rb,
lib/espn/client/standings.rb

Overview

Public: The class that handles the bulk of the work between the API and the wrapper.

Examples

client = ESPN::Client.new(api_key: 'abc123')
# => ESPN::Client

Defined Under Namespace

Modules: Athletes, Audio, Headlines, Medals, Notes, Now, Scores, Sports, Standings, Teams, Video

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Video

#videos

Methods included from Teams

#team, #teams

Methods included from Standings

#standings

Methods included from Sports

#sports

Methods included from Scores

#score, #scores

Methods included from Now

#now

Methods included from Notes

#note, #notes

Methods included from Medals

#medals

Methods included from Headlines

#headline, #headlines

Methods included from Audio

#audio

Methods included from Athletes

#athlete, #athletes

Methods included from Helpers

#blank?

Methods included from Request

#get

Constructor Details

#initialize(opts = {}) ⇒ Client

Public: Initialize a new Client. To see all options that can be configured, look at the Configuration module, specifically VALID_OPTIONS_KEYS.

opts - A Hash of configuration options.



52
53
54
55
56
57
# File 'lib/espn/client.rb', line 52

def initialize(opts={})
  options = ESPN.options.merge(opts)
  Configuration::VALID_OPTIONS_KEYS.each do |key|
    send("#{key}=", options[key])
  end
end

Instance Attribute Details

#adapterObject

Public: Gets/Sets the Symbol adapter.



27
28
29
# File 'lib/espn/client.rb', line 27

def adapter
  @adapter
end

#api_keyObject

Public: Gets/Sets the String api key.



33
34
35
# File 'lib/espn/client.rb', line 33

def api_key
  @api_key
end

#api_versionObject

Public: Gets/Sets the Fixnum api version.



30
31
32
# File 'lib/espn/client.rb', line 30

def api_version
  @api_version
end

#open_timeoutObject

Public: Gets/Sets the Fixnum open timeout.



36
37
38
# File 'lib/espn/client.rb', line 36

def open_timeout
  @open_timeout
end

#proxyObject

Public: Gets/Sets the String proxy.



39
40
41
# File 'lib/espn/client.rb', line 39

def proxy
  @proxy
end

#timeoutObject

Public: Gets/Sets the Fixnum timeout.



42
43
44
# File 'lib/espn/client.rb', line 42

def timeout
  @timeout
end

#user_agentObject

Public: Gets/Sets the String user agent.



45
46
47
# File 'lib/espn/client.rb', line 45

def user_agent
  @user_agent
end

Instance Method Details

#api_urlObject

Public: Get the base URL for accessing the ESPN API.

Returns a String.



62
63
64
# File 'lib/espn/client.rb', line 62

def api_url
  "http://api.espn.com/v1/"
end

#authed?Boolean

Public: Determine if the ESPN::Client has been authenticated. At this point, we are just checking to see if an :api_key has been set.

Returns a Boolean.

Returns:

  • (Boolean)


70
71
72
# File 'lib/espn/client.rb', line 70

def authed?
  !api_key.nil?
end