Module: ESPN::Client::Audio

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

Instance Method Summary collapse

Instance Method Details

#audio(opts = {}) ⇒ Object

Public: Get audio podcasts and clips from ESPN.

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

- :method         - The name of the sport (default: 'podcasts').
- :podast_id      - The id of the podcast (default: nil).
- :recording_id   - The id of the recording (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
31
32
33
# File 'lib/espn/client/audio.rb', line 13

def audio(opts={})
  opts [:method] ||= 'podcasts'

  url = 'audio'

  if opts[:method] == 'podcast_recordings'
    url += '/podcasts/recordings'
  else
    url += "/#{opts[:method]}"
  end

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

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

  get(url, opts)
end