Class: Buzzsprout::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/buzzsprout/client.rb

Class Method Summary collapse

Class Method Details

.episode(podcast_id, episode_id) ⇒ Episode

Retrieve episode details

Parameters:

  • podcast_id (Fixnum)

    The ID for the podcast

  • episode_id (Fixnum)

    The ID for the episode

Returns:

  • (Episode)

    A list of episodes matching the query



26
27
28
# File 'lib/buzzsprout/client.rb', line 26

def self.episode(podcast_id, episode_id)
  Buzzsprout::Episode.new(self.get("/#{podcast_id}/#{episode_id}.json")['episode'])
end

.episode_from_url(url) ⇒ Episode

Retrieve episode details

Parameters:

  • url (Fixnum)

    URL of the episode

Returns:

  • (Episode)

    A list of episodes matching the query



34
35
36
37
# File 'lib/buzzsprout/client.rb', line 34

def self.episode_from_url(url)
  podcast_id, episode_id = url.split("/").map{|seg| seg.to_i}.reject{|i| i < 1 }
  self.episode(podcast_id, episode_id)
end

.episodes(podcast_id, tags = []) ⇒ Array<Episode>

List all the episodes for a podcast

Parameters:

  • podcast_id (Fixnum)

    The ID for the podcast

  • tags (Array<String>) (defaults to: [])

    An array of tags to filter episodes

Returns:

  • (Array<Episode>)

    A list of episodes matching the query



13
14
15
16
17
18
19
# File 'lib/buzzsprout/client.rb', line 13

def self.episodes(podcast_id, tags=[])
  query = {}
  tags = tags.join(",") if tags.is_a?(Array)
  query[:tags] = tags if tags and not tags.empty?
  response = self.get("/#{podcast_id}.json", :query => query)
  response.map{|item| Buzzsprout::Episode.new(item['episode'])}
end