Module: Picasa::Photo

Includes:
Missing
Defined in:
lib/picasa/photo.rb

Overview

Module that offers methods to do high level operations concerning a album within Picasa.

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Missing

#method_missing

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Picasa::Missing

Instance Attribute Details

#albumObject

Returns the value of attribute album.



68
69
70
# File 'lib/picasa/photo.rb', line 68

def album
  @album
end

#albumidObject (readonly)

Returns the value of attribute albumid.



68
69
70
# File 'lib/picasa/photo.rb', line 68

def albumid
  @albumid
end

#comment_countObject (readonly)

Returns the value of attribute comment_count.



68
69
70
# File 'lib/picasa/photo.rb', line 68

def comment_count
  @comment_count
end

#descriptionObject

Returns the value of attribute description.



73
74
75
# File 'lib/picasa/photo.rb', line 73

def description
  @description
end

#fileObject

Returns the value of attribute file.



73
74
75
# File 'lib/picasa/photo.rb', line 73

def file
  @file
end

#heightObject (readonly)

Returns the value of attribute height.



68
69
70
# File 'lib/picasa/photo.rb', line 68

def height
  @height
end

#media_content_urlObject (readonly)

Returns the value of attribute media_content_url.



68
69
70
# File 'lib/picasa/photo.rb', line 68

def media_content_url
  @media_content_url
end

#media_thumbnail_url1Object (readonly)

Returns the value of attribute media_thumbnail_url1.



68
69
70
# File 'lib/picasa/photo.rb', line 68

def media_thumbnail_url1
  @media_thumbnail_url1
end

#media_thumbnail_url2Object (readonly)

Returns the value of attribute media_thumbnail_url2.



68
69
70
# File 'lib/picasa/photo.rb', line 68

def media_thumbnail_url2
  @media_thumbnail_url2
end

#media_thumbnail_url3Object (readonly)

Returns the value of attribute media_thumbnail_url3.



68
69
70
# File 'lib/picasa/photo.rb', line 68

def media_thumbnail_url3
  @media_thumbnail_url3
end

#media_titleObject (readonly)

Returns the value of attribute media_title.



68
69
70
# File 'lib/picasa/photo.rb', line 68

def media_title
  @media_title
end

#picasa_idObject (readonly)

Returns the value of attribute picasa_id.



68
69
70
# File 'lib/picasa/photo.rb', line 68

def picasa_id
  @picasa_id
end

#sizeObject (readonly)

Returns the value of attribute size.



68
69
70
# File 'lib/picasa/photo.rb', line 68

def size
  @size
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



68
69
70
# File 'lib/picasa/photo.rb', line 68

def timestamp
  @timestamp
end

#widthObject (readonly)

Returns the value of attribute width.



68
69
70
# File 'lib/picasa/photo.rb', line 68

def width
  @width
end

Class Method Details

.included(base) ⇒ Object



64
65
66
# File 'lib/picasa/photo.rb', line 64

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#destroyObject

Delete the current photo from album. If cannot delete, an exception is raised.



139
140
141
142
143
# File 'lib/picasa/photo.rb', line 139

def destroy
  raise_exception? do
    self.destroy
  end
end

#destroy!Object

Delete the current photo from album. If cannot delete, an exception is raised.



128
129
130
131
132
133
134
# File 'lib/picasa/photo.rb', line 128

def destroy!
  resp, data = Picasa::HTTP::Photo.delete_photo user_id, album_id, picasa_id, auth_token
  
  if resp.code != "200" or resp.message != "OK"
    raise Exception, "Error destroying photo: #{resp.message}."
  end
end

#picasa_saveObject

Post a photo into a picasa album. If cannot post, returns false.



95
96
97
98
99
# File 'lib/picasa/photo.rb', line 95

def picasa_save
  raise_exception? do
    self.picasa_save!
  end
end

#picasa_save!Object

Post a photo into a picasa album. If cannot post, an exception is raised.



78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/picasa/photo.rb', line 78

def picasa_save!
  if self.picasa_id and self.picasa_id.length > 0
    return picasa_update!
  end
  
  resp, data = Picasa::HTTP::Photo.post_photo user_id, album_id, auth_token, description, file
  
  if resp.code != "201" or resp.message != "Created"
    raise Exception, "Error posting photo: #{resp.message}."
  end
  
  populate_attributes_from_xml data
end

#picasa_updateObject

Update photo’s file and metadata. If cannot update, returns false.



119
120
121
122
123
# File 'lib/picasa/photo.rb', line 119

def picasa_update
  raise_exception? do
    self.picasa_update!
  end
end

#picasa_update!Object

Update photo’s file and metadata. If cannot update, an exception is raised.



104
105
106
107
108
109
110
111
112
113
114
# File 'lib/picasa/photo.rb', line 104

def picasa_update!
  resp, data = Picasa::HTTP::Photo.update_photo(
    'bandmanagertest', album_id, picasa_id, auth_token, description, file
  )
  
  if resp.code != "200" or resp.message != "OK"
    raise Exception, "Error updating photo: #{resp.message}."
  end
  
  populate_attributes_from_xml data
end