Class: Flickr::People::Person
Overview
wrapping class to hold an flickr photo
Instance Attribute Summary collapse
-
#icon_farm ⇒ Object
Returns the value of attribute icon_farm.
-
#icon_server ⇒ Object
Returns the value of attribute icon_server.
-
#is_admin ⇒ Object
Returns the value of attribute is_admin.
-
#is_pro ⇒ Object
Returns the value of attribute is_pro.
-
#location ⇒ Object
Returns the value of attribute location.
-
#mbox_sha1sum ⇒ Object
Returns the value of attribute mbox_sha1sum.
-
#nsid ⇒ Object
Returns the value of attribute nsid.
-
#photo_count ⇒ Object
Returns the value of attribute photo_count.
-
#photo_first_taken ⇒ Object
Returns the value of attribute photo_first_taken.
-
#photo_first_upload ⇒ Object
Returns the value of attribute photo_first_upload.
-
#photos_url ⇒ Object
Returns the value of attribute photos_url.
-
#profile_url ⇒ Object
Returns the value of attribute profile_url.
-
#realname ⇒ Object
Returns the value of attribute realname.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #buddy_icon ⇒ Object
-
#initialize(flickr, attributes) ⇒ Person
constructor
create a new instance of a flickr person.
-
#public_photos(options = {}) ⇒ Object
Get a list of public photos for the given user.
Constructor Details
#initialize(flickr, attributes) ⇒ Person
create a new instance of a flickr person.
Params
-
flickr (Required)
the flickr object
-
attributes (Required)
a hash of attributes used to set the initial values of the person object
13 14 15 16 17 18 |
# File 'lib/flickr/person.rb', line 13 def initialize(flickr, attributes) @flickr = flickr attributes.each do |k,v| send("#{k}=", v) end end |
Instance Attribute Details
#icon_farm ⇒ Object
Returns the value of attribute icon_farm.
4 5 6 |
# File 'lib/flickr/person.rb', line 4 def icon_farm @icon_farm end |
#icon_server ⇒ Object
Returns the value of attribute icon_server.
4 5 6 |
# File 'lib/flickr/person.rb', line 4 def icon_server @icon_server end |
#is_admin ⇒ Object
Returns the value of attribute is_admin.
4 5 6 |
# File 'lib/flickr/person.rb', line 4 def is_admin @is_admin end |
#is_pro ⇒ Object
Returns the value of attribute is_pro.
4 5 6 |
# File 'lib/flickr/person.rb', line 4 def is_pro @is_pro end |
#location ⇒ Object
Returns the value of attribute location.
4 5 6 |
# File 'lib/flickr/person.rb', line 4 def location @location end |
#mbox_sha1sum ⇒ Object
Returns the value of attribute mbox_sha1sum.
4 5 6 |
# File 'lib/flickr/person.rb', line 4 def mbox_sha1sum @mbox_sha1sum end |
#nsid ⇒ Object
Returns the value of attribute nsid.
4 5 6 |
# File 'lib/flickr/person.rb', line 4 def nsid @nsid end |
#photo_count ⇒ Object
Returns the value of attribute photo_count.
4 5 6 |
# File 'lib/flickr/person.rb', line 4 def photo_count @photo_count end |
#photo_first_taken ⇒ Object
Returns the value of attribute photo_first_taken.
4 5 6 |
# File 'lib/flickr/person.rb', line 4 def photo_first_taken @photo_first_taken end |
#photo_first_upload ⇒ Object
Returns the value of attribute photo_first_upload.
4 5 6 |
# File 'lib/flickr/person.rb', line 4 def photo_first_upload @photo_first_upload end |
#photos_url ⇒ Object
Returns the value of attribute photos_url.
4 5 6 |
# File 'lib/flickr/person.rb', line 4 def photos_url @photos_url end |
#profile_url ⇒ Object
Returns the value of attribute profile_url.
4 5 6 |
# File 'lib/flickr/person.rb', line 4 def profile_url @profile_url end |
#realname ⇒ Object
Returns the value of attribute realname.
4 5 6 |
# File 'lib/flickr/person.rb', line 4 def realname @realname end |
#username ⇒ Object
Returns the value of attribute username.
4 5 6 |
# File 'lib/flickr/person.rb', line 4 def username @username end |
Instance Method Details
#buddy_icon ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/flickr/person.rb', line 20 def buddy_icon @buddy_icon ||= if icon_server.to_i > 0 "http://farm#{icon_farm}.static.flickr.com/#{icon_server}/buddyicons/#{nsid}.jpg" else 'http://www.flickr.com/images/buddyicon.jpg' end end |
#public_photos(options = {}) ⇒ Object
Get a list of public photos for the given user.
Options
-
safe_search (Optional)
Safe search setting: 1 for safe. 2 for moderate. 3 for restricted. (Please note: Un-authed calls can only see Safe content.)
-
per_page (Optional)
Number of photos to return per page. If this argument is omitted, it defaults to 100. The maximum allowed value is 500.
-
page (Optional)
The page of results to return. If this argument is omitted, it defaults to 1.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/flickr/person.rb', line 41 def public_photos( = {}) .merge!({:user_id => self.nsid, :extras => "license,date_upload,date_taken,owner_name,icon_server,original_format,last_update,geo,tags,machine_tags,o_dims,views,media"}) rsp = @flickr.send_request('flickr.people.getPublicPhotos', ) returning Flickr::Photos::PhotoResponse.new(:page => rsp.photos[:page].to_i, :pages => rsp.photos[:pages].to_i, :per_page => rsp.photos[:perpage].to_i, :total => rsp.photos[:total].to_i, :photos => [], :api => self, :method => 'public_photos', :options => ) do |photos| rsp.photos.xpath("photo").each do |photo| attributes = Flickr::Photos.create_attributes(photo) photos << Flickr::Photos::Photo.new(@flickr, attributes) end if rsp.photos.at_xpath("photo") end end |