Class: RubyTapasDownloader::Downloadables::File
- Inherits:
-
RubyTapasDownloader::Downloadable
- Object
- RubyTapasDownloader::Downloadable
- RubyTapasDownloader::Downloadables::File
- Defined in:
- lib/ruby_tapas_downloader/downloadables/file.rb
Overview
The File resource of an Episode.
Instance Attribute Summary collapse
-
#link ⇒ String
readonly
The link to download the File.
-
#name ⇒ String
readonly
The name of the File.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#download(basepath, agent) ⇒ Object
Download the File.
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name, link) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(name, link) ⇒ File
Returns a new instance of File.
11 12 13 14 |
# File 'lib/ruby_tapas_downloader/downloadables/file.rb', line 11 def initialize(name, link) @name = name @link = link end |
Instance Attribute Details
#link ⇒ String (readonly)
Returns the link to download the File.
9 10 11 |
# File 'lib/ruby_tapas_downloader/downloadables/file.rb', line 9 def link @link end |
#name ⇒ String (readonly)
Returns the name of the File.
6 7 8 |
# File 'lib/ruby_tapas_downloader/downloadables/file.rb', line 6 def name @name end |
Instance Method Details
#==(other) ⇒ Object
28 29 30 |
# File 'lib/ruby_tapas_downloader/downloadables/file.rb', line 28 def ==(other) name == other.name && link == other.link end |
#download(basepath, agent) ⇒ Object
Download the File.
19 20 21 22 23 24 25 26 |
# File 'lib/ruby_tapas_downloader/downloadables/file.rb', line 19 def download(basepath, agent) FileUtils.mkdir_p basepath file_path = File.join(basepath, name) RubyTapasDownloader.logger.info "Starting download of file `#{ name }' " \ "in `#{ file_path }'..." agent.download link, file_path unless File.exist? file_path end |
#eql?(other) ⇒ Boolean
32 33 34 |
# File 'lib/ruby_tapas_downloader/downloadables/file.rb', line 32 def eql?(other) name.eql?(other.name) && link.eql?(other.link) end |
#hash ⇒ Object
36 37 38 |
# File 'lib/ruby_tapas_downloader/downloadables/file.rb', line 36 def hash name.hash + link.hash end |