Class: RubyTapasDownloader::Downloadables::Catalog

Inherits:
RubyTapasDownloader::Downloadable show all
Defined in:
lib/ruby_tapas_downloader/downloadables/catalog.rb

Overview

Catalog is the set of all Ruby Tapas Episodes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(episodes) ⇒ Catalog

Returns a new instance of Catalog.



8
9
10
# File 'lib/ruby_tapas_downloader/downloadables/catalog.rb', line 8

def initialize(episodes)
  @episodes = episodes
end

Instance Attribute Details

#episodesSet<RubyTapasDownloader::Downloadables::Episode> (readonly)

Returns the Episodes.

Returns:



6
7
8
# File 'lib/ruby_tapas_downloader/downloadables/catalog.rb', line 6

def episodes
  @episodes
end

Instance Method Details

#==(other) ⇒ Object



23
24
25
# File 'lib/ruby_tapas_downloader/downloadables/catalog.rb', line 23

def ==(other)
  episodes == other.episodes
end

#download(basepath, agent) ⇒ Object

Download the Catalog.

Parameters:

  • basepath (String)

    the path to place download.

  • agent (Mechanize)

    the Mechanize agent.



16
17
18
19
20
21
# File 'lib/ruby_tapas_downloader/downloadables/catalog.rb', line 16

def download(basepath, agent)
  RubyTapasDownloader.logger.info 'Starting download of catalog in ' \
                                  "`#{ basepath }'..."
  FileUtils.mkdir_p basepath
  episodes.each { |episode| episode.download basepath, agent }
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/ruby_tapas_downloader/downloadables/catalog.rb', line 27

def eql?(other)
  episodes.eql? other.episodes
end

#hashObject



31
32
33
# File 'lib/ruby_tapas_downloader/downloadables/catalog.rb', line 31

def hash
  episodes.hash
end