Class: Flickr::PhotoSet
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#photo_count ⇒ Object
Returns the value of attribute photo_count.
-
#title ⇒ Object
Returns the value of attribute title.
Attributes inherited from Base
Class Method Summary collapse
-
.find(user_id, id) ⇒ Object
Get information regarding set by searching with the set’s ID.
-
.list(user_id) ⇒ Object
Class methods require scope of the user, it is to be sent into the method.
Instance Method Summary collapse
-
#initialize(id, title, description, photo_count) ⇒ PhotoSet
constructor
A new instance of PhotoSet.
-
#machine_tags ⇒ Object
Return a list of machine_tags for the set Queries: > photosets.getPhotos (1 call) > Photo.find ID (n calls).
-
#photos ⇒ Object
Get the photos within a set Queries: > photosets.getPhotos (1 call) > Photo.find ID (n calls).
-
#similar ⇒ Object
Search for photosets that have similar tags.
-
#tags ⇒ Object
Return a list of tags for the set Queries: > photosets.getPhotos (1 call) > Photo.find ID (n calls).
Methods inherited from Base
Constructor Details
#initialize(id, title, description, photo_count) ⇒ PhotoSet
Returns a new instance of PhotoSet.
4 5 6 |
# File 'lib/flickr-wrapper/photoset.rb', line 4 def initialize id, title, description, photo_count @id, @title, @description, @photo_count = id, title, description, photo_count end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
2 3 4 |
# File 'lib/flickr-wrapper/photoset.rb', line 2 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'lib/flickr-wrapper/photoset.rb', line 2 def id @id end |
#photo_count ⇒ Object
Returns the value of attribute photo_count.
2 3 4 |
# File 'lib/flickr-wrapper/photoset.rb', line 2 def photo_count @photo_count end |
#title ⇒ Object
Returns the value of attribute title.
2 3 4 |
# File 'lib/flickr-wrapper/photoset.rb', line 2 def title @title end |
Class Method Details
.find(user_id, id) ⇒ Object
Get information regarding set by searching with the set’s ID
15 16 17 18 19 20 21 22 |
# File 'lib/flickr-wrapper/photoset.rb', line 15 def self.find user_id, id # Keep scope of the user that made the call @user_id = user_id query = Flickr::Query.new(@user_id).execute('flickr.photosets.getInfo', :photoset_id => id) # Find should return a single entity parse(query).first end |
.list(user_id) ⇒ Object
Class methods require scope of the user, it is to be sent into the method
9 10 11 12 |
# File 'lib/flickr-wrapper/photoset.rb', line 9 def self.list user_id query = Flickr::Query.new user_id parse(query.execute('flickr.photosets.getList')) end |
Instance Method Details
#machine_tags ⇒ Object
Return a list of machine_tags for the set Queries: > photosets.getPhotos (1 call) > Photo.find ID (n calls)
52 53 54 55 56 57 58 59 60 |
# File 'lib/flickr-wrapper/photoset.rb', line 52 def = [] photos.each do |photo| photo..each do |tag| << tag end end .uniq end |
#photos ⇒ Object
Get the photos within a set Queries: > photosets.getPhotos (1 call) > Photo.find ID (n calls)
28 29 30 31 32 |
# File 'lib/flickr-wrapper/photoset.rb', line 28 def photos return (Flickr::Query.new(user_id).execute('flickr.photosets.getPhotos', :photoset_id => id)/:photo).parallel_map(Flickr::MAX_THREADS) do |photo| Flickr::Photo.find user_id, photo[:id] end end |
#similar ⇒ Object
Search for photosets that have similar tags
63 64 65 66 67 68 69 |
# File 'lib/flickr-wrapper/photoset.rb', line 63 def similar sets = [] Flickr::PhotoSet.list(user_id).each do |set| sets << set unless (self. & set.).empty? or set == self end sets.uniq end |
#tags ⇒ Object
Return a list of tags for the set Queries: > photosets.getPhotos (1 call) > Photo.find ID (n calls)
38 39 40 41 42 43 44 45 46 |
# File 'lib/flickr-wrapper/photoset.rb', line 38 def = [] photos.each do |photo| photo..each do |tag| << tag.value end end .uniq end |