Class: Flickr::Person
- Inherits:
-
Object
- Object
- Flickr::Person
- Defined in:
- lib/flickr/base.rb
Instance Attribute Summary collapse
-
#bandwidth_max ⇒ Object
Returns the value of attribute bandwidth_max.
-
#bandwidth_used ⇒ Object
Returns the value of attribute bandwidth_used.
-
#family ⇒ Object
Returns the value of attribute family.
-
#filesize_max ⇒ Object
Returns the value of attribute filesize_max.
-
#friend ⇒ Object
Returns the value of attribute friend.
-
#iconserver ⇒ Object
Returns the value of attribute iconserver.
-
#ignored ⇒ Object
Returns the value of attribute ignored.
-
#info_fetched ⇒ Object
Returns the value of attribute info_fetched.
-
#isadmin ⇒ Object
Returns the value of attribute isadmin.
-
#ispro ⇒ Object
Returns the value of attribute ispro.
-
#location ⇒ Object
Returns the value of attribute location.
-
#mbox_sha1sum ⇒ Object
Returns the value of attribute mbox_sha1sum.
-
#nsid ⇒ Object
Returns the value of attribute nsid.
-
#photos_count ⇒ Object
Returns the value of attribute photos_count.
-
#photos_firstdate ⇒ Object
Returns the value of attribute photos_firstdate.
-
#photos_firstdatetaken ⇒ Object
Returns the value of attribute photos_firstdatetaken.
-
#photosurl ⇒ Object
Returns the value of attribute photosurl.
-
#profileurl ⇒ Object
Returns the value of attribute profileurl.
-
#realname ⇒ Object
Returns the value of attribute realname.
-
#upload_fetched ⇒ Object
Returns the value of attribute upload_fetched.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
-
.from_xml(xml, flickr = nil) ⇒ Object
I think this will define a class method.
Instance Method Summary collapse
- #full_info ⇒ Object
-
#initialize(flickr, nsid, username) ⇒ Person
constructor
A new instance of Person.
- #upload_status ⇒ Object
Constructor Details
#initialize(flickr, nsid, username) ⇒ Person
Returns a new instance of Person.
262 263 264 265 266 267 268 |
# File 'lib/flickr/base.rb', line 262 def initialize(flickr, nsid, username) @flickr = flickr @nsid = nsid @username = username @info_fetched = false @upload_fetched = false end |
Instance Attribute Details
#bandwidth_max ⇒ Object
Returns the value of attribute bandwidth_max.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def bandwidth_max @bandwidth_max end |
#bandwidth_used ⇒ Object
Returns the value of attribute bandwidth_used.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def bandwidth_used @bandwidth_used end |
#family ⇒ Object
Returns the value of attribute family.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def family @family end |
#filesize_max ⇒ Object
Returns the value of attribute filesize_max.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def filesize_max @filesize_max end |
#friend ⇒ Object
Returns the value of attribute friend.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def friend @friend end |
#iconserver ⇒ Object
Returns the value of attribute iconserver.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def iconserver @iconserver end |
#ignored ⇒ Object
Returns the value of attribute ignored.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def ignored @ignored end |
#info_fetched ⇒ Object
Returns the value of attribute info_fetched.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def info_fetched @info_fetched end |
#isadmin ⇒ Object
Returns the value of attribute isadmin.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def isadmin @isadmin end |
#ispro ⇒ Object
Returns the value of attribute ispro.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def ispro @ispro end |
#location ⇒ Object
Returns the value of attribute location.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def location @location end |
#mbox_sha1sum ⇒ Object
Returns the value of attribute mbox_sha1sum.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def mbox_sha1sum @mbox_sha1sum end |
#nsid ⇒ Object
Returns the value of attribute nsid.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def nsid @nsid end |
#photos_count ⇒ Object
Returns the value of attribute photos_count.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def photos_count @photos_count end |
#photos_firstdate ⇒ Object
Returns the value of attribute photos_firstdate.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def photos_firstdate @photos_firstdate end |
#photos_firstdatetaken ⇒ Object
Returns the value of attribute photos_firstdatetaken.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def photos_firstdatetaken @photos_firstdatetaken end |
#photosurl ⇒ Object
Returns the value of attribute photosurl.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def photosurl @photosurl end |
#profileurl ⇒ Object
Returns the value of attribute profileurl.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def profileurl @profileurl end |
#realname ⇒ Object
Returns the value of attribute realname.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def realname @realname end |
#upload_fetched ⇒ Object
Returns the value of attribute upload_fetched.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def upload_fetched @upload_fetched end |
#username ⇒ Object
Returns the value of attribute username.
256 257 258 |
# File 'lib/flickr/base.rb', line 256 def username @username end |
Class Method Details
.from_xml(xml, flickr = nil) ⇒ Object
I think this will define a class method. You can’t use Flickr::Person.from_xml and if you just say Person.from_xml, it can’t resolve Flickr::Person::Person
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/flickr/base.rb', line 280 def self.from_xml(xml,flickr=nil) els = xml.elements att = xml.root.attributes nsid = cond_attr(att,'nsid') username = cond_text(els,'/person/username') p = flickr.person_cache_lookup(nsid) if flickr p ||= Flickr::Person.new(flickr,nsid,username) p.username = username p.isadmin = cond_attr(att,'isadmin') && cond_attr(att,'isadmin') == '1' p.ispro = cond_attr(att,'ispro') && cond_attr(att,'ispro') == '1' p.iconserver = cond_attr(att,'iconserver') && cond_attr(att,'iconserver').to_i p.realname = cond_text(els,'/person/realname') p.mbox_sha1sum = cond_text(els,'/person/mbox_sha1sum') p.location = cond_text(els,'/person/location') p.photosurl = cond_text(els,'/person/photosurl') p.profileurl = cond_text(els,'/person/profileurl') tstr = cond_text(els,'/person/photos/firstdate') p.photos_firstdate = Time.at(tstr.to_i) if tstr tstr = cond_text(els, '/person/photos/firstdatetaken') p.photos_firstdatetaken = Time.gm(*ParseDate.parsedate(tstr)) if tstr p.photos_count = cond_text(els,'/person/photos/count') p.photos_count = p.photos_count if p.photos_count p.info_fetched = true if p.photos_count if els['/user/bandwidth'] att = els['/user/bandwidth'].attributes p.bandwidth_max = cond_attr(att,'max') && cond_attr(att,'max').to_i p.bandwidth_used = cond_attr(att,'used') && cond_attr(att,'used').to_i end if els['/user/filesize'] att = els['/user/filesize'].attributes p.filesize_max = cond_attr(att,'max') && cond_attr(att,'max').to_i end p.upload_fetched = true if p.bandwidth_max flickr.person_cache_store(p) if flickr return p end |
Instance Method Details
#full_info ⇒ Object
270 271 272 |
# File 'lib/flickr/base.rb', line 270 def full_info() self.info_fetched ? self : @flickr.people.getInfo(self) end |
#upload_status ⇒ Object
273 274 |
# File 'lib/flickr/base.rb', line 273 def upload_status() self.upload_fetched ? self : @flickr.people.getUploadStatus(self) end |