Class: RubyTapasDownloader::Downloadables::Episode
- Inherits:
-
RubyTapasDownloader::Downloadable
- Object
- RubyTapasDownloader::Downloadable
- RubyTapasDownloader::Downloadables::Episode
- Defined in:
- lib/ruby_tapas_downloader/downloadables/episode.rb
Overview
An Ruby Tapas Episode.
Instance Attribute Summary collapse
-
#files ⇒ Set<RubyTapasDownloader::Downloadables::File>
readonly
The Set of Files for that episode.
-
#link ⇒ String
readonly
The link to the Episode.
-
#title ⇒ String
readonly
The title of the Episode.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#download(basepath, agent) ⇒ Object
Download the Episode.
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(title, link, files) ⇒ Episode
constructor
A new instance of Episode.
-
#sanitized_title ⇒ String
Clean title to be used in path names.
Constructor Details
#initialize(title, link, files) ⇒ Episode
Returns a new instance of Episode.
15 16 17 18 19 |
# File 'lib/ruby_tapas_downloader/downloadables/episode.rb', line 15 def initialize(title, link, files) @title = title @link = link @files = files end |
Instance Attribute Details
#files ⇒ Set<RubyTapasDownloader::Downloadables::File> (readonly)
Returns the Set of Files for that episode.
13 14 15 |
# File 'lib/ruby_tapas_downloader/downloadables/episode.rb', line 13 def files @files end |
#link ⇒ String (readonly)
Returns the link to the Episode.
9 10 11 |
# File 'lib/ruby_tapas_downloader/downloadables/episode.rb', line 9 def link @link end |
#title ⇒ String (readonly)
Returns the title of the Episode.
6 7 8 |
# File 'lib/ruby_tapas_downloader/downloadables/episode.rb', line 6 def title @title end |
Instance Method Details
#==(other) ⇒ Object
39 40 41 |
# 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) ⇒ Object
Download the Episode.
31 32 33 34 35 36 37 |
# 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) ⇒ Boolean
43 44 45 |
# 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 ⇒ Object
47 48 49 |
# File 'lib/ruby_tapas_downloader/downloadables/episode.rb', line 47 def hash title.hash + link.hash + files.hash end |
#sanitized_title ⇒ String
Clean title to be used in path names.
24 25 26 |
# File 'lib/ruby_tapas_downloader/downloadables/episode.rb', line 24 def sanitized_title @sanitized_title ||= title.downcase.gsub(/[^\w<>#?!$]+/, '-') end |