Class: SimpleImagesDownloader::Client
- Inherits:
-
Object
- Object
- SimpleImagesDownloader::Client
- Defined in:
- lib/simple_images_downloader/client.rb
Overview
Client class Responsible for opening the URI and handling errors
Instance Method Summary collapse
-
#initialize(options = Configuration::REQUEST_OPTIONS) ⇒ Client
constructor
A new instance of Client.
-
#open(uri) ⇒ StringIO
StringIO object.
Constructor Details
#initialize(options = Configuration::REQUEST_OPTIONS) ⇒ Client
Returns a new instance of Client.
13 14 15 |
# File 'lib/simple_images_downloader/client.rb', line 13 def initialize( = Configuration::REQUEST_OPTIONS) @options = end |
Instance Method Details
#open(uri) ⇒ StringIO
Returns StringIO object.
19 20 21 22 23 24 25 |
# File 'lib/simple_images_downloader/client.rb', line 19 def open(uri) uri.open(@options) rescue OpenURI::HTTPRedirect raise Errors::RedirectError, uri rescue OpenURI::HTTPError raise Errors::ConnectionError, uri end |