Class: Net::Flickr::Person

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(flickr, person_xml) ⇒ Person

Returns a new instance of Person.



35
36
37
38
39
40
41
# File 'lib/net/flickr/person.rb', line 35

def initialize(flickr, person_xml)
  @flickr = flickr
  
  @id       = person_xml['nsid']
  @username = person_xml.at('username').inner_text
  @infoxml  = nil
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



33
34
35
# File 'lib/net/flickr/person.rb', line 33

def id
  @id
end

#usernameObject (readonly)

Returns the value of attribute username.



33
34
35
# File 'lib/net/flickr/person.rb', line 33

def username
  @username
end

Instance Method Details

#admin?Boolean

true if this person is a Flickr admin, false otherwise.

Returns:

  • (Boolean)


48
49
50
51
# File 'lib/net/flickr/person.rb', line 48

def admin?
  infoxml = get_info
  return infoxml['isadmin'] == '1'
end

#contact?Boolean

true if this person is a contact of the calling user, false otherwise. This method requires authentication with read permission. In all other cases, it returns false.

Returns:

  • (Boolean)


56
57
58
59
60
61
62
63
64
# File 'lib/net/flickr/person.rb', line 56

def contact?
  infoxml = get_info
  
  if contact = infoxml['contact']
    return contact == '1'
  end
  
  return false
end

#family?Boolean

true if this person is a family member of the calling user, false otherwise. This method requires authentication with read permission. In all other cases, it returns false.

Returns:

  • (Boolean)


69
70
71
72
73
74
75
76
77
# File 'lib/net/flickr/person.rb', line 69

def family?
  infoxml = get_info
  
  if family = infoxml['family']
    return family == '1'
  end
  
  return false
end

#friend?Boolean

true if this person is a friend of the calling user, false otherwise. This method requires authentication with read permission. In all other cases, it returns false.

Returns:

  • (Boolean)


82
83
84
85
86
87
88
89
90
# File 'lib/net/flickr/person.rb', line 82

def friend?
  infoxml = get_info
  
  if friend = infoxml['friend']
    return friend == '1'
  end
  
  return false
end

#genderObject

Gets this person’s gender (e.g., ‘M’). This method requires authentication with read permission and only returns information for contacts of the calling user. In all other cases, it returns nil.



95
96
97
98
# File 'lib/net/flickr/person.rb', line 95

def gender
  infoxml = get_info      
  return infoxml['gender']
end

#groupsObject

TODO: Implement Flickr.person.groups



101
102
# File 'lib/net/flickr/person.rb', line 101

def groups
end

#icon_urlObject

Gets the URL of this person’s buddy icon.



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/net/flickr/person.rb', line 105

def icon_url
  infoxml = get_info
  
  icon_server = infoxml['iconserver']
  icon_farm   = infoxml['iconfarm']
  
  if icon_server.to_i <= 0
    return 'http://www.flickr.com/images/buddyicon.jpg'
  else
    return "http://farm#{icon_farm}.static.flickr.com/#{icon_server}/buddyicons/#{@id}.jpg"
  end
end

#ignored?Boolean

true if this person is an ignored contact of the calling user, false otherwise. This method requires authentication with read permission and only returns information for contacts of the calling user. In all other cases, it returns false.

Returns:

  • (Boolean)


122
123
124
125
126
127
128
129
130
# File 'lib/net/flickr/person.rb', line 122

def ignored?
  infoxml = get_info
  
  if ignored = infoxml['ignored']
    return ignored == '1'
  end
  
  return false
end

#locationObject

Gets this person’s location.



133
134
135
136
# File 'lib/net/flickr/person.rb', line 133

def location
  infoxml = get_info
  return infoxml.at('location').inner_text
end

#mobile_urlObject

Gets the mobile URL of this person’s photos.



139
140
141
142
# File 'lib/net/flickr/person.rb', line 139

def mobile_url
  infoxml = get_info
  return infoxml.at('mobileurl').inner_text
end

#photo_countObject

Gets the total number of photos uploaded by this user.



145
146
147
148
# File 'lib/net/flickr/person.rb', line 145

def photo_count
  infoxml = get_info
  return infoxml.at('photos/count').inner_text.to_i
end

#photo_urlObject

Gets the URL of this person’s photo stream.



151
152
153
154
# File 'lib/net/flickr/person.rb', line 151

def photo_url
  infoxml = get_info
  return infoxml.at('photosurl').inner_text
end

#photo_viewsObject

Gets the number of times this person’s photo stream has been viewed. This method requires authentication with read permission and only returns information for the calling user. In all other cases, it returns nil.



159
160
161
162
163
164
165
166
167
# File 'lib/net/flickr/person.rb', line 159

def photo_views
  infoxml = get_info
  
  if views = infoxml.at('photos/views')
    return views.inner_text.to_i
  end
   
  return nil
end

#photos(args = {}) ⇒ Object

Gets a list of public photos for this person.

See flickr.com/services/api/flickr.people.getPublicPhotos.html for details.



173
174
175
# File 'lib/net/flickr/person.rb', line 173

def photos(args = {})
  return @flickr.photos.user(@id, args)
end

#pro?Boolean

true if this person is a Flickr Pro user, false otherwise.

Returns:

  • (Boolean)


178
179
180
181
# File 'lib/net/flickr/person.rb', line 178

def pro?
  infoxml = get_info
  return infoxml['ispro'] == '1'
end

#profile_urlObject

Gets the URL of this person’s profile.



184
185
186
187
# File 'lib/net/flickr/person.rb', line 184

def profile_url
  infoxml = get_info
  return infoxml.at('profileurl').inner_text
end

#realnameObject

Gets this person’s real name (e.g., ‘John Doe’).



190
191
192
193
# File 'lib/net/flickr/person.rb', line 190

def realname
  infoxml = get_info
  return infoxml.at('realname').inner_text
end

#rev_contact?Boolean

true if the calling user is a contact of this person, false otherwise. This method requires authentication with read permission. In all other cases, it returns false.

Returns:

  • (Boolean)


198
199
200
201
202
203
204
205
206
# File 'lib/net/flickr/person.rb', line 198

def rev_contact?
  infoxml = get_info
  
  if rev_contact = infoxml['revcontact']
    return rev_contact == '1'
  end
  
  return false
end

#rev_family?Boolean

true if this person considers the calling user family, false otherwise. This method requires authentication with read permission. In all other cases, it returns false.

Returns:

  • (Boolean)


211
212
213
214
215
216
217
218
219
# File 'lib/net/flickr/person.rb', line 211

def rev_family?
  infoxml = get_info
  
  if rev_family = infoxml['revfamily']
    return rev_family == '1'
  end
  
  return false
end

#rev_friend?Boolean

true if this person considers the calling user a friend, false otherwise. This method requires authentication with read permission. In all other cases, it returns false.

Returns:

  • (Boolean)


224
225
226
227
228
229
230
231
232
# File 'lib/net/flickr/person.rb', line 224

def rev_friend?
  infoxml = get_info
  
  if rev_friend = infoxml['revfriend']
    return rev_friend == '1'
  end
  
  return false
end