Class: Fleakr::Objects::User

Inherits:
Object
  • Object
show all
Includes:
Support::Object
Defined in:
lib/fleakr/objects/user.rb

Overview

User

Accessors

This class maps directly onto the flickr.people.* API methods and provides the following attributes for a user:

[id] The ID for this user (also referred to as the NSID in the API docs) [username] This user's username [name] This user's full name (if entered) [location] This user's location (if entered) [photos_url] The direct URL to this user's photostream [profile_url] The direct URL to this user's profile [photos_count] The number of photos that this user has uploaded [icon_url] This user's buddy icon (or a default one if an icon wasn't uploaded) [pro?] Does this user have a pro account? [admin?] Is this user an admin?

Associations

The User class is pretty central to many of the other data available across the system, so there are a few associations available to a user:

[sets] A list of this user's public sets (newest first). See Fleakr::Objects::Set for more information. [groups] A list of this user's public groups. See Fleakr::Objects::Group. [photos] A list of this user's public photos (newest first). See Fleakr::Objects::Photo. [contacts] A list of this user's contacts - these are simply User objects [tags] The tags associated with this user [collections] The top-level collections that this user has created. See Fleakr::Objects::Collection.

Examples

Access to a specific user is typically done through the Fleakr.user method:

user = Fleakr.user('brownout') user.id user.username user.sets user.contacts

Instance Method Summary collapse

Methods included from Support::Object

included

Instance Method Details

#admin?Boolean

Is this user an admin?



77
78
79
# File 'lib/fleakr/objects/user.rb', line 77

def admin?
  (self.admin.to_i == 0) ? false : true
end

#icon_urlObject

This user's buddy icon



82
83
84
85
86
87
88
# File 'lib/fleakr/objects/user.rb', line 82

def icon_url
  if self.icon_server.to_i > 0
    "http://farm#{self.icon_farm}.static.flickr.com/#{self.icon_server}/buddyicons/#{self.id}.jpg"
  else
    'http://www.flickr.com/images/buddyicon.jpg'
  end
end

#load_infoObject

:nodoc:



90
91
92
93
# File 'lib/fleakr/objects/user.rb', line 90

def load_info # :nodoc:
  response = Fleakr::Api::MethodRequest.with_response!('people.getInfo', :user_id => self.id)
  self.populate_from(response.body)
end

#pro?Boolean

Is this a pro account?



72
73
74
# File 'lib/fleakr/objects/user.rb', line 72

def pro?
  (self.pro.to_i == 0) ? false : true
end