Class: Flico::ImageFile
- Inherits:
-
Object
- Object
- Flico::ImageFile
- Defined in:
- lib/flico/image_file.rb
Instance Attribute Summary collapse
-
#keyword ⇒ Object
Returns the value of attribute keyword.
Instance Method Summary collapse
- #fetch_from_flickr ⇒ Object
-
#initialize(keyword) ⇒ ImageFile
constructor
A new instance of ImageFile.
Constructor Details
#initialize(keyword) ⇒ ImageFile
Returns a new instance of ImageFile.
12 13 14 |
# File 'lib/flico/image_file.rb', line 12 def initialize(keyword) @keyword = keyword end |
Instance Attribute Details
#keyword ⇒ Object
Returns the value of attribute keyword.
10 11 12 |
# File 'lib/flico/image_file.rb', line 10 def keyword @keyword end |
Instance Method Details
#fetch_from_flickr ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/flico/image_file.rb', line 16 def fetch_from_flickr Flickr::BaseApi.new.get_photo(keyword) rescue NoImage => e puts "Image not found for keyword '#{keyword}'. Message: #{e.message}. Retrying" unless (tries -= 1).positive? raise ApplicationError, "Failed getting image after retrying #{MAX_KEYWORD_RETRIES} times" end retry rescue FetchingError => e raise ApplicationError, e. end |