Class: Flickr::People::Person

Inherits:
Object
  • Object
show all
Defined in:
lib/flickr/person.rb

Overview

wrapping class to hold an flickr photo

Instance Attribute Summary collapse

Instance Method Summary collapse

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_farmObject

Returns the value of attribute icon_farm.



4
5
6
# File 'lib/flickr/person.rb', line 4

def icon_farm
  @icon_farm
end

#icon_serverObject

Returns the value of attribute icon_server.



4
5
6
# File 'lib/flickr/person.rb', line 4

def icon_server
  @icon_server
end

#is_adminObject

Returns the value of attribute is_admin.



4
5
6
# File 'lib/flickr/person.rb', line 4

def is_admin
  @is_admin
end

#is_proObject

Returns the value of attribute is_pro.



4
5
6
# File 'lib/flickr/person.rb', line 4

def is_pro
  @is_pro
end

#locationObject

Returns the value of attribute location.



4
5
6
# File 'lib/flickr/person.rb', line 4

def location
  @location
end

#mbox_sha1sumObject

Returns the value of attribute mbox_sha1sum.



4
5
6
# File 'lib/flickr/person.rb', line 4

def mbox_sha1sum
  @mbox_sha1sum
end

#nsidObject

Returns the value of attribute nsid.



4
5
6
# File 'lib/flickr/person.rb', line 4

def nsid
  @nsid
end

#photo_countObject

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_takenObject

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_uploadObject

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_urlObject

Returns the value of attribute photos_url.



4
5
6
# File 'lib/flickr/person.rb', line 4

def photos_url
  @photos_url
end

#profile_urlObject

Returns the value of attribute profile_url.



4
5
6
# File 'lib/flickr/person.rb', line 4

def profile_url
  @profile_url
end

#realnameObject

Returns the value of attribute realname.



4
5
6
# File 'lib/flickr/person.rb', line 4

def realname
  @realname
end

#usernameObject

Returns the value of attribute username.



4
5
6
# File 'lib/flickr/person.rb', line 4

def username
  @username
end

Instance Method Details

#buddy_iconObject



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(options = {})
  options.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', options)

  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 => 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