class EasyDownloader::AbstractLoader

Attributes

files[R]
result[R]

Public Class Methods

new(*options) click to toggle source
# File lib/easy_downloader/abstract_loader.rb, line 12
def initialize(*options)
  @options= Options.new(*options)
end

Public Instance Methods

execute() click to toggle source
# File lib/easy_downloader/abstract_loader.rb, line 23
def execute
  begin
    @options.result.started
    execute_load
    @options.result.loaded(@options.load_count)
    @options.result.finished
  rescue Exception => e
    @options.result.errors= error_message(@options, e)
  end
  @result = @options.result
  @files  = @result.loaded
  self
end
execute_load() click to toggle source
# File lib/easy_downloader/abstract_loader.rb, line 17
def execute_load
  [:ftp, :http, :sftp].include?(@options.type.to_sym) ?
    send("#{@options.type}_#{self.class.load_type.to_s}".to_sym, @options) :
    raise(NotImplementedError.new("we don't have an #{@options.type}er of this type."))
end

Private Instance Methods

error_message(options, e) click to toggle source
# File lib/easy_downloader/abstract_loader.rb, line 39
def error_message(options, e)
  raise NotImplementedError.new("#{self.class.name} does not have an 'error_message' method.")
end
local_files_list(options) click to toggle source
# File lib/easy_downloader/abstract_loader.rb, line 43
def local_files_list(options)
  if options.local_file
    [options.local_file]
  else
    Dir[options.local_path, options.local_pattern]
  end
end
options() click to toggle source
# File lib/easy_downloader/abstract_loader.rb, line 51
def options
  @options
end