Class: Picasa::Album

Inherits:
Object
  • Object
show all
Defined in:
lib/picasa/album.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_userObject

Returns the value of attribute google_user.



3
4
5
# File 'lib/picasa/album.rb', line 3

def google_user
  @google_user
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/picasa/album.rb', line 3

def id
  @id
end

#photoObject

Returns the value of attribute photo.



3
4
5
# File 'lib/picasa/album.rb', line 3

def photo
  @photo
end

#photosObject

Returns the value of attribute photos.



3
4
5
# File 'lib/picasa/album.rb', line 3

def photos
  @photos
end

#photos_countObject

Returns the value of attribute photos_count.



3
4
5
# File 'lib/picasa/album.rb', line 3

def photos_count
  @photos_count
end

#summaryObject

Returns the value of attribute summary.



3
4
5
# File 'lib/picasa/album.rb', line 3

def summary
  @summary
end

#thumbnailObject

Returns the value of attribute thumbnail.



3
4
5
# File 'lib/picasa/album.rb', line 3

def thumbnail
  @thumbnail
end

#titleObject

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