Class: EasyDownloader::AbstractLoader

Inherits:
Object
  • Object
show all
Includes:
Ftp, Http, Sftp
Defined in:
lib/easy_downloader/abstract_loader.rb

Direct Known Subclasses

Downloader, Uploader

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Http

#http_download, #password_option

Methods included from Ftp

#change_remote_dir, #ftp_download, #ftp_password_option, #ftp_upload, #open_ftp, #remote_files_list

Methods included from Sftp

#sftp_download, #sftp_password_option

Constructor Details

#initialize(*options) ⇒ AbstractLoader

Returns a new instance of AbstractLoader.



12
13
14
# File 'lib/easy_downloader/abstract_loader.rb', line 12

def initialize(*options)
  @options= Options.new(*options)
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



4
5
6
# File 'lib/easy_downloader/abstract_loader.rb', line 4

def files
  @files
end

#resultObject (readonly)

Returns the value of attribute result.



4
5
6
# File 'lib/easy_downloader/abstract_loader.rb', line 4

def result
  @result
end

Instance Method Details

#executeObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# 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_loadObject



17
18
19
20
21
# 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