Class: Picasa::Album
- Inherits:
-
Object
- Object
- Picasa::Album
- Defined in:
- lib/picasa/album.rb
Instance Attribute Summary collapse
-
#google_user ⇒ Object
Returns the value of attribute google_user.
-
#id ⇒ Object
Returns the value of attribute id.
-
#photo ⇒ Object
Returns the value of attribute photo.
-
#photos ⇒ Object
Returns the value of attribute photos.
-
#photos_count ⇒ Object
Returns the value of attribute photos_count.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
- .all(google_user) ⇒ Object
- .find(google_user, album_id) ⇒ Object
- .parse_xml(google_user, xml_entry) ⇒ Object
Instance Method Summary collapse
-
#initialize(google_user) ⇒ Album
constructor
A new instance of Album.
Constructor Details
#initialize(google_user) ⇒ Album
Returns a new instance of Album.
46 47 48 |
# File 'lib/picasa/album.rb', line 46 def initialize(google_user) self.google_user = google_user end |
Instance Attribute Details
#google_user ⇒ Object
Returns the value of attribute google_user.
3 4 5 |
# File 'lib/picasa/album.rb', line 3 def google_user @google_user end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/picasa/album.rb', line 3 def id @id end |
#photo ⇒ Object
Returns the value of attribute photo.
3 4 5 |
# File 'lib/picasa/album.rb', line 3 def photo @photo end |
#photos ⇒ Object
Returns the value of attribute photos.
3 4 5 |
# File 'lib/picasa/album.rb', line 3 def photos @photos end |
#photos_count ⇒ Object
Returns the value of attribute photos_count.
3 4 5 |
# File 'lib/picasa/album.rb', line 3 def photos_count @photos_count end |
#summary ⇒ Object
Returns the value of attribute summary.
3 4 5 |
# File 'lib/picasa/album.rb', line 3 def summary @summary end |
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
3 4 5 |
# File 'lib/picasa/album.rb', line 3 def thumbnail @thumbnail end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/picasa/album.rb', line 3 def title @title end |
Class Method Details
.all(google_user) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/picasa/album.rb', line 28 def self.all(google_user) data = Picasa::Connection.stablish("/data/feed/api/user/#{google_user}") xml = XmlSimple.xml_in(data) xml['entry'].map do |album_xml_entry| Picasa::Album.parse_xml(google_user, album_xml_entry) end if xml['entry'] end |
.find(google_user, album_id) ⇒ Object
36 37 38 39 40 |
# File 'lib/picasa/album.rb', line 36 def self.find(google_user, album_id) data = Picasa::Connection.stablish("/data/feed/api/user/#{google_user}/albumid/#{album_id}") xml = XmlSimple.xml_in(data) Album.parse_xml(google_user, xml) end |
.parse_xml(google_user, xml_entry) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/picasa/album.rb', line 5 def self.parse_xml(google_user, xml_entry) album = new(google_user) album.id = xml_entry['id'][1] album.title = xml_entry['title'][0]['content'] album.summary = if xml_entry['subtitle'] xml_entry['subtitle'][0]['content'] elsif xml_entry['summary'] xml_entry['summary'][0]['content'] end album.photos_count = xml_entry['numphotos'][0].to_i #has *group* when called from albums list if xml_entry['group'] album.photo = xml_entry['group'][0]['content']['url'] album.thumbnail = xml_entry['group'][0]['thumbnail'][0]['url'] #has *entry* when called from find elsif xml_entry['entry'] album.photos = xml_entry['entry'].map do |photo_xml_entry| Photo.parse_xml(photo_xml_entry) end end album end |