Class: RubyTapasDownloader::Extractors::Files

Inherits:
RubyTapasDownloader::Extractor show all
Defined in:
lib/ruby_tapas_downloader/extractors/files.rb

Overview

Extract a Set of Files from an Feed Item Description.

Instance Method Summary collapse

Instance Method Details

#extract(item_description) ⇒ Set<RubyTapasDownloader::Downloadables::File>

Returns the Set of Files extracted from feed item description.

Parameters:

  • item_description (String)

    the feed item description extracted with ‘feed.items.description`.

Returns:



7
8
9
10
11
12
13
14
15
16
# File 'lib/ruby_tapas_downloader/extractors/files.rb', line 7

def extract(item_description)
  files = Set.new
  document = REXML::Document.new item_description
  document.elements.each("/div[@class='blog-entry']/ul/li/a") do |element|
    name = element.text
    link = element.attribute('href').to_s
    files << RubyTapasDownloader::Downloadables::File.new(name, link)
  end
  files
end