class RubyTapasDownloader::Downloadables::Episode
An Ruby Tapas Episode
.
Attributes
files[R]
@return [Set<RubyTapasDownloader::Downloadables::File>] the Set of Files
for that episode.
link[R]
@return [String] the link to the Episode
.
title[R]
@return [String] the title of the Episode
.
Public Class Methods
new(title, link, files)
click to toggle source
# File lib/ruby_tapas_downloader/downloadables/episode.rb, line 15 def initialize(title, link, files) @title = title @link = link @files = files end
Public Instance Methods
==(other)
click to toggle source
# File lib/ruby_tapas_downloader/downloadables/episode.rb, line 39 def ==(other) title == other.title && link == other.link && files == other.files end
download(basepath, agent)
click to toggle source
Download the Episode
.
@param (see: RubyTapasDownloader::Downloadables::Catalog#download
)
# File lib/ruby_tapas_downloader/downloadables/episode.rb, line 31 def download(basepath, agent) episode_path = File.join basepath, sanitized_title RubyTapasDownloader.logger.info 'Starting download of episode ' \ "`#{ title }' in `#{ episode_path }'..." FileUtils.mkdir_p episode_path files.each { |file| file.download episode_path, agent } end
eql?(other)
click to toggle source
# File lib/ruby_tapas_downloader/downloadables/episode.rb, line 43 def eql?(other) title.eql?(other.title) && link.eql?(other.link) && files.eql?(other.files) end
hash()
click to toggle source
# File lib/ruby_tapas_downloader/downloadables/episode.rb, line 47 def hash title.hash + link.hash + files.hash end
sanitized_title()
click to toggle source
Clean title to be used in path names.
@return [String] the sanitized title.
# File lib/ruby_tapas_downloader/downloadables/episode.rb, line 24 def sanitized_title @sanitized_title ||= title.downcase.gsub(/[^\w<>#?!$]+/, '-') end