Class: MyLocalPutio::Downloader
- Inherits:
-
Object
- Object
- MyLocalPutio::Downloader
- Defined in:
- lib/my-local-putio/downloader.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #download(url, path) ⇒ Object
-
#initialize(configuration) ⇒ Downloader
constructor
A new instance of Downloader.
Constructor Details
#initialize(configuration) ⇒ Downloader
Returns a new instance of Downloader.
5 6 7 8 |
# File 'lib/my-local-putio/downloader.rb', line 5 def initialize(configuration) @configuration = configuration @logger = configuration.logger end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
3 4 5 |
# File 'lib/my-local-putio/downloader.rb', line 3 def configuration @configuration end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
3 4 5 |
# File 'lib/my-local-putio/downloader.rb', line 3 def logger @logger end |
Instance Method Details
#download(url, path) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/my-local-putio/downloader.rb', line 10 def download(url, path) logger.debug "Download file from #{url}" logger.log "Downloading: #{path}" command = download_command(url, path) fetch_result = system(*command) raise "Unable to download #{path}" unless fetch_result logger.log "Finishing the download..." move_downloaded_file!(path) end |