Class: Flico::FetchImage

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

Instance Method Summary collapse

Instance Method Details

#call(url) ⇒ Object



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

def call(url)
  tempfile = Tempfile.new 'temp_image'
  IO.copy_stream(URI.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