Class: Picasa::Photo
- Inherits:
-
Object
- Object
- Picasa::Photo
- Defined in:
- lib/picasa/photo.rb
Instance Attribute Summary collapse
-
#src ⇒ Object
Returns the value of attribute src.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#thumbnail_1 ⇒ Object
Returns the value of attribute thumbnail_1.
-
#thumbnail_2 ⇒ Object
Returns the value of attribute thumbnail_2.
-
#thumbnail_3 ⇒ Object
Returns the value of attribute thumbnail_3.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
- .find_all_by_album_id(google_user, album_id) ⇒ Object
- .find_all_by_tags(google_user, tags) ⇒ Object
- .parse_all_xml(xml_data) ⇒ Object
- .parse_xml(xml_entry) ⇒ Object
Instance Attribute Details
#src ⇒ Object
Returns the value of attribute src.
3 4 5 |
# File 'lib/picasa/photo.rb', line 3 def src @src end |
#tags ⇒ Object
Returns the value of attribute tags.
3 4 5 |
# File 'lib/picasa/photo.rb', line 3 def @tags end |
#thumbnail_1 ⇒ Object
Returns the value of attribute thumbnail_1.
3 4 5 |
# File 'lib/picasa/photo.rb', line 3 def thumbnail_1 @thumbnail_1 end |
#thumbnail_2 ⇒ Object
Returns the value of attribute thumbnail_2.
3 4 5 |
# File 'lib/picasa/photo.rb', line 3 def thumbnail_2 @thumbnail_2 end |
#thumbnail_3 ⇒ Object
Returns the value of attribute thumbnail_3.
3 4 5 |
# File 'lib/picasa/photo.rb', line 3 def thumbnail_3 @thumbnail_3 end |
#title ⇒ Object
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.(google_user, ) = .gsub(' ', '') data = Picasa::Connection.stablish("/data/feed/api/user/#{google_user}?kind=photo&tag=#{}") 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. = xml_entry['group'][0]['keywords'][0] photo.src = xml_entry['content']['src'] photo end |