module Bob

Constants

FETCHERS
VERSION

Public Instance Methods

fetch(url) click to toggle source
# File lib/bob.rb, line 18
def fetch(url)
  url = URI.encode(url)
  host = URI(url).host
  fetcher = FETCHERS[host]

  raise_error(url) if fetcher.nil?
  begin
    fetcher.fetch(url)
  rescue StandardError
    raise_error(url)
  end
end

Private Instance Methods

raise_error(url) click to toggle source
# File lib/bob.rb, line 32
def raise_error(url)
  raise UnprocessableHostError.new("Dont know how to handle #{url}.")
end