Class: Google::Picasa::Photo
- Inherits:
-
Object
- Object
- Google::Picasa::Photo
- Defined in:
- lib/google-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.
480 481 482 |
# File 'lib/google-picasa.rb', line 480 def initialize() thumbnails = [] end |
Instance Attribute Details
#album_id ⇒ Object
Returns the value of attribute album_id.
470 471 472 |
# File 'lib/google-picasa.rb', line 470 def album_id @album_id end |
#client ⇒ Object
Returns the value of attribute client.
472 473 474 |
# File 'lib/google-picasa.rb', line 472 def client @client end |
#description ⇒ Object
Returns the value of attribute description.
469 470 471 |
# File 'lib/google-picasa.rb', line 469 def description @description end |
#edit_url ⇒ Object
Returns the value of attribute edit_url.
478 479 480 |
# File 'lib/google-picasa.rb', line 478 def edit_url @edit_url end |
#height ⇒ Object
Returns the value of attribute height.
474 475 476 |
# File 'lib/google-picasa.rb', line 474 def height @height end |
#id ⇒ Object
Returns the value of attribute id.
468 469 470 |
# File 'lib/google-picasa.rb', line 468 def id @id end |
#is_commentable ⇒ Object
Returns the value of attribute is_commentable.
473 474 475 |
# File 'lib/google-picasa.rb', line 473 def is_commentable @is_commentable end |
#medium ⇒ Object
Returns the value of attribute medium.
474 475 476 |
# File 'lib/google-picasa.rb', line 474 def medium @medium end |
#number_of_comments ⇒ Object
Returns the value of attribute number_of_comments.
473 474 475 |
# File 'lib/google-picasa.rb', line 473 def number_of_comments @number_of_comments end |
#picasa_session ⇒ Object
Returns the value of attribute picasa_session.
466 467 468 |
# File 'lib/google-picasa.rb', line 466 def picasa_session @picasa_session end |
#self_xml_url ⇒ Object
Returns the value of attribute self_xml_url.
478 479 480 |
# File 'lib/google-picasa.rb', line 478 def self_xml_url @self_xml_url end |
#size ⇒ Object
Returns the value of attribute size.
471 472 473 |
# File 'lib/google-picasa.rb', line 471 def size @size end |
#thumbnails ⇒ Object
Returns the value of attribute thumbnails.
475 476 477 |
# File 'lib/google-picasa.rb', line 475 def thumbnails @thumbnails end |
#title ⇒ Object
Returns the value of attribute title.
469 470 471 |
# File 'lib/google-picasa.rb', line 469 def title @title end |
#type ⇒ Object
Returns the value of attribute type.
474 475 476 |
# File 'lib/google-picasa.rb', line 474 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
474 475 476 |
# File 'lib/google-picasa.rb', line 474 def url @url end |
#version_number ⇒ Object
Returns the value of attribute version_number.
477 478 479 |
# File 'lib/google-picasa.rb', line 477 def version_number @version_number end |
#width ⇒ Object
Returns the value of attribute width.
474 475 476 |
# File 'lib/google-picasa.rb', line 474 def width @width end |
#xml ⇒ Object
Returns the value of attribute xml.
476 477 478 |
# File 'lib/google-picasa.rb', line 476 def xml @xml end |
Instance Method Details
#move_to_album(picasa_album_id) ⇒ Object
520 521 522 523 524 525 526 527 528 529 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 |
# File 'lib/google-picasa.rb', line 520 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 = 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
484 485 486 487 488 489 490 491 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 |
# File 'lib/google-picasa.rb', line 484 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 = 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 return true else return false end end |