Class: MyLocalPutio::Downloader

Inherits:
Object
  • Object
show all
Defined in:
lib/my-local-putio/downloader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#configurationObject (readonly)

Returns the value of attribute configuration.



3
4
5
# File 'lib/my-local-putio/downloader.rb', line 3

def configuration
  @configuration
end

#loggerObject (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