Class: Picasa::Album

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAlbum

Returns a new instance of Album.



424
425
426
# File 'lib/picasa.rb', line 424

def initialize()
  thumbnail = Thumbnail.new()
end

Instance Attribute Details

#accessObject

Returns the value of attribute access.



415
416
417
# File 'lib/picasa.rb', line 415

def access
  @access
end

#author_nameObject

Returns the value of attribute author_name.



416
417
418
# File 'lib/picasa.rb', line 416

def author_name
  @author_name
end

#author_uriObject

Returns the value of attribute author_uri.



416
417
418
# File 'lib/picasa.rb', line 416

def author_uri
  @author_uri
end

#descriptionObject

Returns the value of attribute description.



414
415
416
# File 'lib/picasa.rb', line 414

def description
  @description
end

#description_typeObject

Returns the value of attribute description_type.



414
415
416
# File 'lib/picasa.rb', line 414

def description_type
  @description_type
end

#edit_urlObject

Returns the value of attribute edit_url.



422
423
424
# File 'lib/picasa.rb', line 422

def edit_url
  @edit_url
end

#idObject

Returns the value of attribute id.



411
412
413
# File 'lib/picasa.rb', line 411

def id
  @id
end

#image_typeObject

Returns the value of attribute image_type.



419
420
421
# File 'lib/picasa.rb', line 419

def image_type
  @image_type
end

#image_urlObject

Returns the value of attribute image_url.



419
420
421
# File 'lib/picasa.rb', line 419

def image_url
  @image_url
end

#is_commentableObject

Returns the value of attribute is_commentable.



418
419
420
# File 'lib/picasa.rb', line 418

def is_commentable
  @is_commentable
end

#nameObject

Returns the value of attribute name.



411
412
413
# File 'lib/picasa.rb', line 411

def name
  @name
end

#number_of_commentsObject

Returns the value of attribute number_of_comments.



417
418
419
# File 'lib/picasa.rb', line 417

def number_of_comments
  @number_of_comments
end

#number_of_photosObject

Returns the value of attribute number_of_photos.



417
418
419
# File 'lib/picasa.rb', line 417

def number_of_photos
  @number_of_photos
end

#picasa_sessionObject

Returns the value of attribute picasa_session.



409
410
411
# File 'lib/picasa.rb', line 409

def picasa_session
  @picasa_session
end

#self_xml_urlObject

Returns the value of attribute self_xml_url.



422
423
424
# File 'lib/picasa.rb', line 422

def self_xml_url
  @self_xml_url
end

#thumbnailObject

Returns the value of attribute thumbnail.



420
421
422
# File 'lib/picasa.rb', line 420

def thumbnail
  @thumbnail
end

#titleObject

Returns the value of attribute title.



413
414
415
# File 'lib/picasa.rb', line 413

def title
  @title
end

#title_typeObject

Returns the value of attribute title_type.



413
414
415
# File 'lib/picasa.rb', line 413

def title_type
  @title_type
end

#userObject

Returns the value of attribute user.



412
413
414
# File 'lib/picasa.rb', line 412

def user
  @user
end

#xmlObject

Returns the value of attribute xml.



421
422
423
# File 'lib/picasa.rb', line 421

def xml
  @xml
end

Instance Method Details

#create_photos_from_xml(xml_response) ⇒ Object



451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
# File 'lib/picasa.rb', line 451

def create_photos_from_xml(xml_response)
  photos = []
  #response_hash = XmlSimple.xml_in(xml_response, { 'ForceArray' => false })
  #puts response_hash.inspect

  Picasa.entries(xml_response).each do |entry|
    #parse the entry xml element and get the photo object
    photo = Picasa.parse_photo_entry(entry)

    #enter session values in photo object
    photo.picasa_session = PicasaSession.new
    photo.picasa_session.auth_key = self.picasa_session.auth_key
    photo.picasa_session.user_id = self.picasa_session.user_id

    photos << photo
  end

  return photos
end

#photos(options = {}) ⇒ Object



428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
# File 'lib/picasa.rb', line 428

def photos(options = {})

  userId = options[:user_id].nil? ? self.user : options[:user_id]
  albumName = options[:album].nil? ? self.name : options[:album]
  albumId = options[:album_id].nil? ? self.id : options[:album_id]

  if(albumId != nil && albumId != "")
    url = "https://picasaweb.google.com/data/feed/api/user/#{userId}/albumid/#{albumId}?kind=photo"
  else
    url = "https://picasaweb.google.com/data/feed/api/user/#{userId}/album/#{albumName}?kind=photo"
  end

  uri = URI.parse(url)
  http = Net::HTTP.new(uri.host, uri.port)

  headers = {"Authorization" => "GoogleLogin auth=#{self.picasa_session.auth_key}"}

  response, xml_response = http.get(uri.path, headers)
  photos = self.create_photos_from_xml(xml_response)

  return photos
end