Class: Picasa::Photo
- Inherits:
-
Object
- Object
- Picasa::Photo
- Defined in:
- lib/picasa.rb
Instance Attribute Summary collapse
-
#album_id ⇒ Object
Returns the value of attribute album_id.
-
#client ⇒ Object
Returns the value of attribute client.
-
#description ⇒ Object
Returns the value of attribute description.
-
#edit_url ⇒ Object
Returns the value of attribute edit_url.
-
#height ⇒ Object
Returns the value of attribute height.
-
#id ⇒ Object
Returns the value of attribute id.
-
#is_commentable ⇒ Object
Returns the value of attribute is_commentable.
-
#medium ⇒ Object
Returns the value of attribute medium.
-
#number_of_comments ⇒ Object
Returns the value of attribute number_of_comments.
-
#picasa_session ⇒ Object
Returns the value of attribute picasa_session.
-
#self_xml_url ⇒ Object
Returns the value of attribute self_xml_url.
-
#size ⇒ Object
Returns the value of attribute size.
-
#thumbnails ⇒ Object
Returns the value of attribute thumbnails.
-
#title ⇒ Object
Returns the value of attribute title.
-
#type ⇒ Object
Returns the value of attribute type.
-
#url ⇒ Object
Returns the value of attribute url.
-
#version_number ⇒ Object
Returns the value of attribute version_number.
-
#width ⇒ Object
Returns the value of attribute width.
-
#xml ⇒ Object
Returns the value of attribute xml.
Instance Method Summary collapse
-
#initialize ⇒ Photo
constructor
A new instance of Photo.
- #move_to_album(picasa_album_id) ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize ⇒ Photo
Returns a new instance of Photo.
488 489 490 |
# File 'lib/picasa.rb', line 488 def initialize() thumbnails = [] end |
Instance Attribute Details
#album_id ⇒ Object
Returns the value of attribute album_id.
478 479 480 |
# File 'lib/picasa.rb', line 478 def album_id @album_id end |
#client ⇒ Object
Returns the value of attribute client.
480 481 482 |
# File 'lib/picasa.rb', line 480 def client @client end |
#description ⇒ Object
Returns the value of attribute description.
477 478 479 |
# File 'lib/picasa.rb', line 477 def description @description end |
#edit_url ⇒ Object
Returns the value of attribute edit_url.
486 487 488 |
# File 'lib/picasa.rb', line 486 def edit_url @edit_url end |
#height ⇒ Object
Returns the value of attribute height.
482 483 484 |
# File 'lib/picasa.rb', line 482 def height @height end |
#id ⇒ Object
Returns the value of attribute id.
476 477 478 |
# File 'lib/picasa.rb', line 476 def id @id end |
#is_commentable ⇒ Object
Returns the value of attribute is_commentable.
481 482 483 |
# File 'lib/picasa.rb', line 481 def is_commentable @is_commentable end |
#medium ⇒ Object
Returns the value of attribute medium.
482 483 484 |
# File 'lib/picasa.rb', line 482 def medium @medium end |
#number_of_comments ⇒ Object
Returns the value of attribute number_of_comments.
481 482 483 |
# File 'lib/picasa.rb', line 481 def number_of_comments @number_of_comments end |
#picasa_session ⇒ Object
Returns the value of attribute picasa_session.
474 475 476 |
# File 'lib/picasa.rb', line 474 def picasa_session @picasa_session end |
#self_xml_url ⇒ Object
Returns the value of attribute self_xml_url.
486 487 488 |
# File 'lib/picasa.rb', line 486 def self_xml_url @self_xml_url end |
#size ⇒ Object
Returns the value of attribute size.
479 480 481 |
# File 'lib/picasa.rb', line 479 def size @size end |
#thumbnails ⇒ Object
Returns the value of attribute thumbnails.
483 484 485 |
# File 'lib/picasa.rb', line 483 def thumbnails @thumbnails end |
#title ⇒ Object
Returns the value of attribute title.
477 478 479 |
# File 'lib/picasa.rb', line 477 def title @title end |
#type ⇒ Object
Returns the value of attribute type.
482 483 484 |
# File 'lib/picasa.rb', line 482 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
482 483 484 |
# File 'lib/picasa.rb', line 482 def url @url end |
#version_number ⇒ Object
Returns the value of attribute version_number.
485 486 487 |
# File 'lib/picasa.rb', line 485 def version_number @version_number end |
#width ⇒ Object
Returns the value of attribute width.
482 483 484 |
# File 'lib/picasa.rb', line 482 def width @width end |
#xml ⇒ Object
Returns the value of attribute xml.
484 485 486 |
# File 'lib/picasa.rb', line 484 def xml @xml end |
Instance Method Details
#move_to_album(picasa_album_id) ⇒ Object
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 |
# File 'lib/picasa.rb', line 530 def move_to_album(picasa_album_id) updatePhotoXml = "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:gphoto='http://schemas.google.com/photos/2007'> <title type='text'>#{self.title}</title> <summary type='text'>#{self.description}</summary> <gphoto:albumid>#{picasa_album_id}</gphoto:albumid> <gphoto:checksum></gphoto:checksum> <gphoto:client></gphoto:client> <gphoto:rotation>#{0}</gphoto:rotation> <gphoto:timestamp>#{Time.new.to_i.to_s}</gphoto:timestamp> <gphoto:commentingEnabled>#{self.is_commentable.to_s}</gphoto:commentingEnabled> <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#photo'></category> </entry>" url = "http://picasaweb.google.com/data/entry/api/user/#{self.picasa_session.user_id}/albumid/#{self.album_id}/photoid/#{self.id}/#{self.version_number}" uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) headers = {"Content-Type" => "application/atom+xml", "Authorization" => "GoogleLogin auth=#{self.picasa_session.auth_key}"} response, data = http.put(uri.path, updatePhotoXml, headers) data = response.body if(response.code == "200") #parse the entry xml element and get the photo object new_photo = Picasa.parse_photo_entry(XmlSimple.xml_in(data.to_s, { 'ForceArray' => false })) self.version_number = new_photo.version_number self.album_id = new_photo.album_id return true else return false end end |
#update ⇒ Object
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 |
# File 'lib/picasa.rb', line 492 def update() updatePhotoXml = "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:gphoto='http://schemas.google.com/photos/2007'> <title type='text'>#{self.title}</title> <summary type='text'>#{self.description}</summary> <gphoto:checksum></gphoto:checksum> <gphoto:client></gphoto:client> <gphoto:rotation>#{0}</gphoto:rotation> <gphoto:timestamp>#{Time.new.to_i.to_s}</gphoto:timestamp> <gphoto:commentingEnabled>#{self.is_commentable.to_s}</gphoto:commentingEnabled> <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/photos/2007#photo'></category> </entry>" url = "http://picasaweb.google.com/data/entry/api/user/#{self.picasa_session.user_id}/albumid/#{self.album_id}/photoid/#{self.id}/#{self.version_number}" uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) headers = {"Content-Type" => "application/atom+xml", "Authorization" => "GoogleLogin auth=#{self.picasa_session.auth_key}"} response, data = http.put(uri.path, updatePhotoXml, headers) data = response.body if(response.code == "200") #parse the entry xml element and get the photo object #new_photo = Picasa.parse_photo_entry(data) new_photo = Picasa.parse_photo_entry(XmlSimple.xml_in(data.to_s, { 'ForceArray' => false })) self.version_number = new_photo.version_number return true else return false end end |