Class: Hexapic::Repository::FlickrRepository
- Inherits:
-
Object
- Object
- Hexapic::Repository::FlickrRepository
- Defined in:
- lib/hexapic/repository.rb
Constant Summary collapse
- API_KEY =
'bd053065ce6662cb4b2f4c0be2b65266'
Instance Method Summary collapse
- #find_pictures(tags) ⇒ Object
-
#initialize ⇒ FlickrRepository
constructor
A new instance of FlickrRepository.
Constructor Details
#initialize ⇒ FlickrRepository
Returns a new instance of FlickrRepository.
49 50 51 52 |
# File 'lib/hexapic/repository.rb', line 49 def initialize @flickr = Flickr.new(api_key: API_KEY, verify_ssl: false) puts 'Using Flickr' end |
Instance Method Details
#find_pictures(tags) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/hexapic/repository.rb', line 54 def find_pictures() = {} [:tag_mode] = 'and' [:tags] = [:sort] = 'relevance' [:content_type] = '1' [:extras] = 'url_q,url_sq,url_s' puts "Getting last images by tags #{}" pics = @flickr.search().sample(COUNT).map do |photo| Picture.new(photo.source('Large Square'), photo.url, photo.filename) end raise ImagesNotFound.new("Found only #{pics.size} images. Need #{COUNT}.") if pics.size < COUNT pics end |