Class: ImageDownloader::Download

Inherits:
Object
  • Object
show all
Defined in:
lib/image_downloader/download.rb

Class Method Summary collapse

Class Method Details

.consequentially(images, user_agent) ⇒ Object



15
16
17
18
19
20
# File 'lib/image_downloader/download.rb', line 15

def self.consequentially(images, user_agent)
  for image in images
    p "upload from url #{image.absolute_src} to file #{image.file_name}" if $debug_option
    image.download(user_agent)
  end
end

.parallel(images, user_agent) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/image_downloader/download.rb', line 4

def self.parallel(images, user_agent)
  threads = []
  for image in images
    threads << Thread.new(image) {|local_image|
      p "upload from url #{local_image.absolute_src} to file #{local_image.file_name}" if $debug_option
      local_image.download(user_agent)
    }
  end
  threads.each { |aThread|  aThread.join }
end