Class: Google::Picasa::Photo

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePhoto

Returns a new instance of Photo.



480
481
482
# File 'lib/google-picasa.rb', line 480

def initialize()
  thumbnails = []
end

Instance Attribute Details

#album_idObject

Returns the value of attribute album_id.



470
471
472
# File 'lib/google-picasa.rb', line 470

def album_id
  @album_id
end

#clientObject

Returns the value of attribute client.



472
473
474
# File 'lib/google-picasa.rb', line 472

def client
  @client
end

#descriptionObject

Returns the value of attribute description.



469
470
471
# File 'lib/google-picasa.rb', line 469

def description
  @description
end

#edit_urlObject

Returns the value of attribute edit_url.



478
479
480
# File 'lib/google-picasa.rb', line 478

def edit_url
  @edit_url
end

#heightObject

Returns the value of attribute height.



474
475
476
# File 'lib/google-picasa.rb', line 474

def height
  @height
end

#idObject

Returns the value of attribute id.



468
469
470
# File 'lib/google-picasa.rb', line 468

def id
  @id
end

#is_commentableObject

Returns the value of attribute is_commentable.



473
474
475
# File 'lib/google-picasa.rb', line 473

def is_commentable
  @is_commentable
end

#mediumObject

Returns the value of attribute medium.



474
475
476
# File 'lib/google-picasa.rb', line 474

def medium
  @medium
end

#number_of_commentsObject

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_sessionObject

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_urlObject

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

#sizeObject

Returns the value of attribute size.



471
472
473
# File 'lib/google-picasa.rb', line 471

def size
  @size
end

#thumbnailsObject

Returns the value of attribute thumbnails.



475
476
477
# File 'lib/google-picasa.rb', line 475

def thumbnails
  @thumbnails
end

#titleObject

Returns the value of attribute title.



469
470
471
# File 'lib/google-picasa.rb', line 469

def title
  @title
end

#typeObject

Returns the value of attribute type.



474
475
476
# File 'lib/google-picasa.rb', line 474

def type
  @type
end

#urlObject

Returns the value of attribute url.



474
475
476
# File 'lib/google-picasa.rb', line 474

def url
  @url
end

#version_numberObject

Returns the value of attribute version_number.



477
478
479
# File 'lib/google-picasa.rb', line 477

def version_number
  @version_number
end

#widthObject

Returns the value of attribute width.



474
475
476
# File 'lib/google-picasa.rb', line 474

def width
  @width
end

#xmlObject

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

#updateObject



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