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

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?

Returns:

  • (Boolean)


75
76
77
# File 'lib/fleakr/objects/user.rb', line 75

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

#icon_urlObject

This user’s buddy icon



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

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:



88
89
90
91
# File 'lib/fleakr/objects/user.rb', line 88

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?

Returns:

  • (Boolean)


70
71
72
# File 'lib/fleakr/objects/user.rb', line 70

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