Class: Flickr::Token
- Inherits:
-
Object
- Object
- Flickr::Token
- Defined in:
- lib/flickr/base.rb
Instance Attribute Summary collapse
-
#perms ⇒ Object
readonly
Returns the value of attribute perms.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(token, perms, user) ⇒ Token
constructor
A new instance of Token.
- #to_xml ⇒ Object
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
#perms ⇒ Object (readonly)
Returns the value of attribute perms.
211 212 213 |
# File 'lib/flickr/base.rb', line 211 def perms @perms end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
211 212 213 |
# File 'lib/flickr/base.rb', line 211 def token @token end |
#user ⇒ Object (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_xml ⇒ Object
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 |