Class: Flickr::Token

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, perms, user) ⇒ Token

Returns a new instance of Token.



213
214
215
216
217
# File 'lib/flickr/base.rb', line 213

def initialize(token, perms, user)
	@token = token
	@perms = perms
	@user = user
end

Instance Attribute Details

#permsObject (readonly)

Returns the value of attribute perms.



211
212
213
# File 'lib/flickr/base.rb', line 211

def perms
  @perms
end

#tokenObject (readonly)

Returns the value of attribute token.



211
212
213
# File 'lib/flickr/base.rb', line 211

def token
  @token
end

#userObject (readonly)

Returns the value of attribute user.



211
212
213
# File 'lib/flickr/base.rb', line 211

def user
  @user
end

Class Method Details

.from_xml(xml, flickr = nil) ⇒ Object



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/flickr/base.rb', line 219

def self.from_xml(xml, flickr=nil)
	token = xml.elements['/auth/token'].text
	perms = xml.elements['/auth/perms'].text.intern
	user = xml.elements['/auth/user']
	nsid = user.attributes['nsid']
	username = user.attributes['username']
	fullname = user.attributes['fullname']

	p = flickr.person_cache_lookup(nsid) if flickr
	p ||= Flickr::Person.new(flickr,nsid,username)
	p.realname=fullname
	flickr.person_cache_store(p) if flickr

	return Flickr::Token.new(token,perms,p)
end

Instance Method Details

#to_xmlObject



235
236
237
238
239
240
241
# File 'lib/flickr/base.rb', line 235

def to_xml
	    return "<auth><token>#{self.token}</token>"+
	           "<perms>#{self.perms}</perms>"+
		   "<user nsid=\"#{self.user.nsid}\" "+
		   "username=\"#{self.user.username}\" "+
		   "fullname=\"#{self.user.realname}\" /></auth>"
end