Class: Flico::FetchImage

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

Instance Method Summary collapse

Instance Method Details

#call(url) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/flico/saver.rb', line 13

def call(url)
  tempfile = Tempfile.new 'temp_image'
  IO.copy_stream(open(url, read_timeout: 5), tempfile)
  tempfile.rewind
  tempfile
  rescue OpenURI::HTTPError => e
  raise FetchingError, "Couldn't download from: #{url} due to #{e.message}"
end