class StaticImageDownloader::Downloader
Attributes
Public Class Methods
# File lib/static_image_download.rb, line 55 def self.default_path @@DEFAULTPATH end
This is just for info: user_agent - Parse::DEFAULTUSERAGENT = 'Mozilla/5.0' parse_timeout - Parse::DEFAULTTIMEOUT = 10 parse_option - Parse::DEFAULTPARSEOPTION = 'URI_EXTRACT' # also you can use one 'NOKOGIRI' or 'HPRICOT' download_timeout - Image::DEFAULTTIMEOUT = 120 Image::DEFAULTDONWLOADOPTION = 'CURB_EASY' # also you can use 'HTTP_GET' allow_dup_files - dup_file_names = false # don't get file if exists one allow_dup_files - dup_file_names [DEFAULT option]= true # get file if it exists as new one and add numerical prefix (1,2,3, etc.) to it's name
# File lib/static_image_download.rb, line 49 def initialize(url, path=@@DEFAULTPATH) @url = url @path = path.nil? ? @@DEFAULTPATH : path @images = [] end
Public Instance Methods
# File lib/static_image_download.rb, line 75 def consequential_download(download_option='CURB_EASY', download_timeout=120, allow_dup_files=true) self.images.each { |img| img.download(download_option, download_timeout, :dup_file_names => allow_dup_files) } p "Total " + Images::get_successfull_pictures_number + " pictures were got" end
# File lib/static_image_download.rb, line 66 def parallel_download(download_option='CURB_EASY', download_timeout=120, allow_dup_files=true) threads = [] self.images.each do |img| threads << Thread.new(img) { |image| image.download(download_option, download_timeout, :dup_file_names => allow_dup_files) } end threads.each { |aThread| aThread.join } p "Total " + Images::get_successfull_pictures_number + " pictures were got" end
# File lib/static_image_download.rb, line 59 def parse_images(parse_option='URI_EXTRACT', parse_timeout=10, user_agent='Mozilla/5.0') parser = Parser.new(self.url, self.path, parse_option, parse_timeout, user_agent) parser.get_content_raw parser.parse_images self.images = parser.images end