Class: Flickr::User

Inherits:
Base
  • Object
show all
Defined in:
lib/flickr-wrapper/user.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#user_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#machine_tags, #photos, #sets, #tags

Constructor Details

#initialize(username, nsid) ⇒ User

Returns a new instance of User.



4
5
6
# File 'lib/flickr-wrapper/user.rb', line 4

def initialize username, nsid
  @username, @nsid = username, nsid
end

Instance Attribute Details

#nsidObject

Returns the value of attribute nsid.



2
3
4
# File 'lib/flickr-wrapper/user.rb', line 2

def nsid
  @nsid
end

#usernameObject

Returns the value of attribute username.



2
3
4
# File 'lib/flickr-wrapper/user.rb', line 2

def username
  @username
end

Class Method Details

.find_by_email(email) ⇒ Object

Class methods



12
13
14
15
# File 'lib/flickr-wrapper/user.rb', line 12

def self.find_by_email email
  result = Flickr::Query.new('').execute('flickr.people.findByEmail', :find_email => email)
  return Flickr::User.new(result.at(:username).inner_text, result.at(:user)['nsid'])
end

.find_by_username(username) ⇒ Object



17
18
19
20
# File 'lib/flickr-wrapper/user.rb', line 17

def self.find_by_username username
  result = Flickr::Query.new('').execute('flickr.people.findByUsername', :username => username)
  return Flickr::User.new(result.at(:username).inner_text, result.at(:user)['nsid'])
end

Instance Method Details

#buddy_icon?Boolean

Do they have a buddy icon or not?

Returns:

  • (Boolean)


41
42
43
# File 'lib/flickr-wrapper/user.rb', line 41

def buddy_icon?
  (icon_server > 0) ? true : false 
end

#buddy_icon_urlObject



45
46
47
# File 'lib/flickr-wrapper/user.rb', line 45

def buddy_icon_url
  buddy_icon? ? "http://farm#{icon_farm}.static.flickr.com/#{icon_server}/buddyicons/#{nsid}.jpg" : "http://www.flickr.com/images/buddyicon.jpg"
end

#locationObject

The location string as entered in flickr



31
32
33
# File 'lib/flickr-wrapper/user.rb', line 31

def location
  get_info.at(:location).inner_text || "Unknown"
end

#pro?Boolean

has the user shelled out for flickr-pro account?

Returns:

  • (Boolean)


36
37
38
# File 'lib/flickr-wrapper/user.rb', line 36

def pro?
  (get_info.at(:person)["ispro"] == "1") ? true : false 
end

#realnameObject

Instance methods



26
27
28
# File 'lib/flickr-wrapper/user.rb', line 26

def realname
  get_info.at(:realname).inner_text
end