Module: Alexandria::ImageFetcher

Included in:
Library, UI::AcquireDialog, UI::NewBookDialog
Defined in:
lib/alexandria/image_fetcher.rb

Instance Method Summary collapse

Instance Method Details

#fetch_image(uri) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/alexandria/image_fetcher.rb', line 11

def fetch_image(uri)
  result = nil
  if URI.parse(uri).scheme.nil?
    File.open(uri, "r") do |io|
      result = io.read
    end
  else
    result = WWWAgent.new.get(uri)
  end
  result
rescue Errno::ECONNRESET
  nil
end