class RubyTapasDownloader::Extractors::Catalog

Extract an Catalog from an Feed.

Public Class Methods

new(episode_extractor = RubyTapasDownloader::Extractors::Episode.new) click to toggle source

@param episode_extractor [RubyTapasDownloader::Extractors::Episode] the

Episode Extractor.
# File lib/ruby_tapas_downloader/extractors/catalog.rb, line 5
def initialize(episode_extractor =
                                 RubyTapasDownloader::Extractors::Episode.new)
  @episode_extractor = episode_extractor
end

Public Instance Methods

extract(feed) click to toggle source

@param feed [RSS::Rss] the feed extracted with ‘RSS::Parser.parse`. @return [RubyTapasDownloader::Downloadables::Catalog] the Catalog extracted

from feed.
# File lib/ruby_tapas_downloader/extractors/catalog.rb, line 13
def extract(feed)
  episodes = Set.new

  feed.items.each do |item|
    episodes << @episode_extractor.extract(item)
  end

  RubyTapasDownloader::Downloadables::Catalog.new episodes
end