Class: ImageDownloader

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

Class Method Summary collapse

Class Method Details

.download(path, url) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ImageDownloader.rb', line 6

def self.download(path, url)
    dir = path.split("/")
    dir.pop()
    Helper.createDirIfNotExist(dir.join("/"))
    
    begin
        imageResponse = URI.open(url)
        File.write(path, imageResponse.read)
        true
    rescue
        false
    end
end