Module: Gig::Downloader
- Defined in:
- lib/gig/downloader.rb
Class Method Summary collapse
Class Method Details
.run(directory, filename, uri) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/gig/downloader.rb', line 4 def self.run(directory, filename, uri) Dir.mkdir(directory) unless Dir.exist?(directory) path = "#{Dir.pwd}/#{directory}/#{filename}.jpg" return false if File.exist?(path) URI.open(path, 'wb') do |file| puts "Downloading #{filename}.jpg to #{Dir.pwd}/#{directory}" file << URI.open(uri).read end true end |