Class: Flickr::Photo
Defined Under Namespace
Classes: Size
Instance Attribute Summary collapse
-
#caller ⇒ Object
Returns the value of attribute caller.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#machine_tags ⇒ Object
Returns the value of attribute machine_tags.
-
#posted ⇒ Object
Returns the value of attribute posted.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#taken ⇒ Object
Returns the value of attribute taken.
-
#title ⇒ Object
Returns the value of attribute title.
Attributes inherited from Base
Class Method Summary collapse
-
.find(user_id, id) ⇒ Object
Find will grab all sizes of images, process the tags and standard attributes of a photo.
- .list(user_id) ⇒ Object
-
.search(user_id, search_options = {}) ⇒ Object
Find a collection of photos by text Search options should be hashes with string values or arrays for multiple values.
Instance Method Summary collapse
-
#initialize(id, title, description) ⇒ Photo
constructor
A new instance of Photo.
- #sizes ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(id, title, description) ⇒ Photo
Returns a new instance of Photo.
6 7 8 |
# File 'lib/flickr-wrapper/photo.rb', line 6 def initialize(id, title, description) @id, @title, @description = id, title, description end |
Instance Attribute Details
#caller ⇒ Object
Returns the value of attribute caller.
4 5 6 |
# File 'lib/flickr-wrapper/photo.rb', line 4 def caller @caller end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/flickr-wrapper/photo.rb', line 4 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/flickr-wrapper/photo.rb', line 4 def id @id end |
#machine_tags ⇒ Object
Returns the value of attribute machine_tags.
4 5 6 |
# File 'lib/flickr-wrapper/photo.rb', line 4 def @machine_tags end |
#posted ⇒ Object
Returns the value of attribute posted.
4 5 6 |
# File 'lib/flickr-wrapper/photo.rb', line 4 def posted @posted end |
#tags ⇒ Object
Returns the value of attribute tags.
4 5 6 |
# File 'lib/flickr-wrapper/photo.rb', line 4 def @tags end |
#taken ⇒ Object
Returns the value of attribute taken.
4 5 6 |
# File 'lib/flickr-wrapper/photo.rb', line 4 def taken @taken end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/flickr-wrapper/photo.rb', line 4 def title @title end |
Class Method Details
.find(user_id, id) ⇒ Object
Find will grab all sizes of images, process the tags and standard attributes of a photo
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/flickr-wrapper/photo.rb', line 15 def self.find(user_id, id) photo_call = Flickr::Query.new(user_id).execute('flickr.photos.getInfo', :photo_id => id) # Set basic attributes photo = self.new(id, *%w(title description).map {|a| (photo_call/a).inner_text }) photo.taken = Time.parse(photo_call.at(:dates)['taken']) photo.posted = Time.at(photo_call.at(:dates)['posted'].to_i) # Set tags for photo photo. = (photo_call/"tag[@machine_tag=0]").map{|tag| Flickr::Tag.new tag['raw'] } photo. = (photo_call/"tag[@machine_tag=1]").map{|tag| Flickr::MachineTag.from_s tag['raw'] } return photo end |
.list(user_id) ⇒ Object
10 11 12 |
# File 'lib/flickr-wrapper/photo.rb', line 10 def self.list(user_id) search(user_id) end |
.search(user_id, search_options = {}) ⇒ Object
Find a collection of photos by text Search options should be hashes with string values or arrays for multiple values
32 33 34 |
# File 'lib/flickr-wrapper/photo.rb', line 32 def self.search(user_id, ={}) parse(user_id, Flickr::Query.new(user_id).execute('flickr.photos.search', )) end |
Instance Method Details
#sizes ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/flickr-wrapper/photo.rb', line 36 def sizes hash = {} (Flickr::Query.new(user_id).execute('flickr.photos.getSizes', :photo_id => id)/:size).parallel_each(Flickr::MAX_THREADS) do |size| hash[size['label'].downcase.to_sym] = Size.new(*%w(width height source url).map{|a| size[a]}) end return hash end |