Module: ESPN::Client::Scores

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

Instance Method Summary collapse

Instance Method Details

#scores(opts = {}) ⇒ Object

Public: Get schedule and scores information from 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).
- :event_id - The event to get information about (default: nil).

Returns an Array of Hashie::Mash.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/espn/client/scores.rb', line 13

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

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

  url += '/events'

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

  get(url, opts)
end