Class: ImgFetcher::URL
- Inherits:
-
Object
- Object
- ImgFetcher::URL
- Defined in:
- lib/img_fetcher/url.rb
Class Method Summary collapse
-
.download(line) ⇒ Object
On sucess: returns a Tempfile.
Class Method Details
.download(line) ⇒ Object
On sucess: returns a Tempfile. On failure: returns nil.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/img_fetcher/url.rb', line 6 def self.download(line) Down.download(line, max_redirects: 0) # Decided to rescue all Down exceptions since they are all related to connection and URL. # By rescuing the exceptions, execution will continue and the rest of the URLs will be # downloaded. # We can notice that we could have one the following: Down::TooLarge, Down::InvalidUrl, # Down::TooManyRedirects, Down::ResponseError, Down::ClientError, Down::NotFound, # Down::ServerError, Down::ConnectionError, Down::TimeoutError, Down::SSLError. rescue Down::Error, Addressable::URI::InvalidURIError nil end |