Module: ESPN::Client::Audio

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

Overview

Public: The mapping to the AUDIO API of the ESPN developer API.

Examples

class Client
  include ESPN::Client::Audio
end

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. If sport and/or

league are passed in, they will override the mapped values
You can find a full list of options on the ESPN developer API
website (default: {}).
:method       - The name of the sport (default: 'podcasts').
:podcast_id   - The id of the podcast (default: nil).
:recording_id - The id of the recording (default: nil).

Returns an Array of Hashie::Mash.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/espn/client/audio.rb', line 24

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

  # Correct invalid method.
  if opts[:method] == 'podcast_recordings'
    opts[:method] = 'podcasts/recordings'
  end

  pattern = "audio/#{opts[:method]}/:podcast_id/:recording_id"
  get(pattern, opts).recordings
end