Class: Picasa::Photo

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#srcObject

Returns the value of attribute src.



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

def src
  @src
end

#tagsObject

Returns the value of attribute tags.



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

def tags
  @tags
end

#thumbnail_1Object

Returns the value of attribute thumbnail_1.



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

def thumbnail_1
  @thumbnail_1
end

#thumbnail_2Object

Returns the value of attribute thumbnail_2.



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

def thumbnail_2
  @thumbnail_2
end

#thumbnail_3Object

Returns the value of attribute thumbnail_3.



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

def thumbnail_3
  @thumbnail_3
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

Class Method Details

.find_all_by_album_id(google_user, album_id) ⇒ Object



5
6
7
8
# File 'lib/picasa/photo.rb', line 5

def self.find_all_by_album_id(google_user, album_id)
  data = Picasa::Connection.stablish("/data/feed/api/user/#{google_user}/albumid/#{album_id}")
  Photo.parse_all_xml(data)
end

.find_all_by_tags(google_user, tags) ⇒ Object



10
11
12
13
14
# File 'lib/picasa/photo.rb', line 10

def self.find_all_by_tags(google_user, tags)
  tags = tags.gsub(' ', '')
  data = Picasa::Connection.stablish("/data/feed/api/user/#{google_user}?kind=photo&tag=#{tags}")
  Photo.parse_all_xml(data)
end

.parse_all_xml(xml_data) ⇒ Object



27
28
29
30
31
32
# File 'lib/picasa/photo.rb', line 27

def self.parse_all_xml(xml_data)
  xml = XmlSimple.xml_in(xml_data)
  xml['entry'].map do |photo_xml_entry|
    Photo.parse_xml(photo_xml_entry)
  end if xml['entry']
end

.parse_xml(xml_entry) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/picasa/photo.rb', line 16

def self.parse_xml(xml_entry)
  photo = new
  photo.title = xml_entry['group'][0]['description'][0]['content']
  photo.thumbnail_1 = xml_entry['group'][0]['thumbnail'][0]['url']
  photo.thumbnail_2 = xml_entry['group'][0]['thumbnail'][1]['url']
  photo.thumbnail_3 = xml_entry['group'][0]['thumbnail'][2]['url']
  photo.tags = xml_entry['group'][0]['keywords'][0]
  photo.src = xml_entry['content']['src']
  photo
end