Module: ESPN::Client::Sports

Included in:
ESPN::Client
Defined in:
lib/espn/client/sports.rb

Instance Method Summary collapse

Instance Method Details

#sports(opts = {}) ⇒ Object

Public: Get sports and leagues supported in the ESPN API.

opts - Hash options used to refine the selection (default: {}).

- :sport - The name of the sport (default: nil).
- :league - The name of the league (default: nil).

Returns an Array of Hashie::Mash.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/espn/client/sports.rb', line 12

def sports(opts={})
  url = 'sports'

  unless opts[:sport].to_s.empty?
    url += "/#{opts[:sport]}"
    unless opts[:league].to_s.empty?
      url += "/#{opts[:league]}"
    end
  end

  get(url, opts)
end