Sha256: 8e48ca5d8797d1ea394a42159d24947ebba858fb9480c50d798e8cd55a610fc1

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

module Buzzsprout
  
  class Client
    include HTTParty
    format :json
    base_uri "http://www.buzzsprout.com"

    # List all the episodes for a podcast
    #
    # @param [Fixnum] podcast_id The ID for the podcast
    # @param [Array<String>] tags An array of tags to filter episodes
    # @return [Array<Episode>] A list of episodes matching the query
    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

    # Retrieve episode details
    #
    # @param [Fixnum] podcast_id The ID for the podcast
    # @param [Fixnum] episode_id The ID for the episode
    # @return [Episode] A list of episodes matching the query
    def self.episode(podcast_id, episode_id)
      Buzzsprout::Episode.new(self.get("/#{podcast_id}/#{episode_id}.json")['episode'])
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
buzzsprout-0.0.2 lib/buzzsprout/client.rb