Class: Imagemaster3000::Utils::Tmp
- Inherits:
-
Object
- Object
- Imagemaster3000::Utils::Tmp
- Defined in:
- lib/imagemaster3000/utils/tmp.rb
Class Method Summary collapse
Class Method Details
.destroy(file) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/imagemaster3000/utils/tmp.rb', line 16 def self.destroy(file) return unless file logger.debug "Closing tempfile #{file.path.inspect}" file.close file.unlink end |
.download(url) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/imagemaster3000/utils/tmp.rb', line 6 def self.download(url) file = Tempfile.new('imagemaster3000') logger.debug "Downloading file from url #{url} to tempfile #{file.path.inspect}" download = URI.parse(url).open IO.copy_stream(download, file) file.rewind file end |