Class: Picasa::WebAlbums
- Inherits:
-
Object
- Object
- Picasa::WebAlbums
- Defined in:
- lib/picasa/web_albums.rb
Instance Attribute Summary collapse
-
#google_user ⇒ Object
Returns the value of attribute google_user.
Instance Method Summary collapse
- #albums ⇒ Object
-
#initialize(google_user) ⇒ WebAlbums
constructor
A new instance of WebAlbums.
- #photos(album_id) ⇒ Object
Constructor Details
#initialize(google_user) ⇒ WebAlbums
Returns a new instance of WebAlbums.
5 6 7 |
# File 'lib/picasa/web_albums.rb', line 5 def initialize(google_user) @google_user = google_user end |
Instance Attribute Details
#google_user ⇒ Object
Returns the value of attribute google_user.
3 4 5 |
# File 'lib/picasa/web_albums.rb', line 3 def google_user @google_user end |
Instance Method Details
#albums ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/picasa/web_albums.rb', line 9 def albums data = connect("/data/feed/api/user/#{google_user}") xml=XmlSimple.xml_in(data) albums = [] xml['entry'].each do |album| attributes = {} attributes[:id] = album['id'][1] attributes[:title] = album['title'][0]['content'] attributes[:photos_count] = album['numphotos'][0].to_i albums << attributes end albums end |
#photos(album_id) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/picasa/web_albums.rb', line 23 def photos(album_id) data = connect("/data/feed/api/user/#{google_user}/albumid/#{album_id}") xml = XmlSimple.xml_in(data) photos = [] xml['entry'].each do |photo| attributes = {} attributes[:title] = photo['group'][0]['description'][0]['content'] #returns nil if empty attributes[:thumbnail_1] = photo['group'][0]['thumbnail'][0]['url'] attributes[:thumbnail_2] = photo['group'][0]['thumbnail'][1]['url'] attributes[:thumbnail_3] = photo['group'][0]['thumbnail'][2]['url'] #attributes[:photo] << photo['group'][0]['content']['url'] attributes[:photo] = photo['content']['src'] photos << attributes end { :photos => photos, :slideshow => xml['link'][2]['href'] } end |