Module: Picasa::Album

Includes:
Missing
Defined in:
lib/picasa/album.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

#accessObject

Returns the value of attribute access.



89
90
91
# File 'lib/picasa/album.rb', line 89

def access
  @access
end

#author_nameObject (readonly)

Returns the value of attribute author_name.



85
86
87
# File 'lib/picasa/album.rb', line 85

def author_name
  @author_name
end

#author_uriObject (readonly)

Returns the value of attribute author_uri.



85
86
87
# File 'lib/picasa/album.rb', line 85

def author_uri
  @author_uri
end

#comment_countObject (readonly)

Returns the value of attribute comment_count.



85
86
87
# File 'lib/picasa/album.rb', line 85

def comment_count
  @comment_count
end

#commenting_enableObject (readonly)

Returns the value of attribute commenting_enable.



85
86
87
# File 'lib/picasa/album.rb', line 85

def commenting_enable
  @commenting_enable
end

#keywordsObject

Returns the value of attribute keywords.



89
90
91
# File 'lib/picasa/album.rb', line 89

def keywords
  @keywords
end

Returns the value of attribute link_edit.



85
86
87
# File 'lib/picasa/album.rb', line 85

def link_edit
  @link_edit
end

#locationObject

Returns the value of attribute location.



89
90
91
# File 'lib/picasa/album.rb', line 89

def location
  @location
end

#media_content_urlObject (readonly) Also known as: cover_url

Returns the value of attribute media_content_url.



85
86
87
# File 'lib/picasa/album.rb', line 85

def media_content_url
  @media_content_url
end

#media_thumbnail_urlObject (readonly) Also known as: thumbnail_url

Returns the value of attribute media_thumbnail_url.



85
86
87
# File 'lib/picasa/album.rb', line 85

def media_thumbnail_url
  @media_thumbnail_url
end

#nicknameObject (readonly)

Returns the value of attribute nickname.



85
86
87
# File 'lib/picasa/album.rb', line 85

def nickname
  @nickname
end

#num_photosObject (readonly)

Returns the value of attribute num_photos.



85
86
87
# File 'lib/picasa/album.rb', line 85

def num_photos
  @num_photos
end

#picasa_idObject (readonly)

Returns the value of attribute picasa_id.



85
86
87
# File 'lib/picasa/album.rb', line 85

def picasa_id
  @picasa_id
end

#summaryObject

Returns the value of attribute summary.



89
90
91
# File 'lib/picasa/album.rb', line 89

def summary
  @summary
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



85
86
87
# File 'lib/picasa/album.rb', line 85

def timestamp
  @timestamp
end

#titleObject

Returns the value of attribute title.



89
90
91
# File 'lib/picasa/album.rb', line 89

def title
  @title
end

#userObject

Returns the value of attribute user.



85
86
87
# File 'lib/picasa/album.rb', line 85

def user
  @user
end

Class Method Details

.included(base) ⇒ Object



81
82
83
# File 'lib/picasa/album.rb', line 81

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

Instance Method Details

#find_photo(photo_id) ⇒ Object



194
195
196
# File 'lib/picasa/album.rb', line 194

def find_photo photo_id
  photo_class.picasa_find user_id, picasa_id, photo_id, auth_token
end

#photos(reload = false) ⇒ Object

Find all photos from the current album. The operation is done only one time for an instance, if it it’s needed to do it to refresh the data you can pass the parameter true so it can be reloaded.



202
203
204
205
# File 'lib/picasa/album.rb', line 202

def photos(reload = false)
  @photos = photo_class.picasa_find_all user_id, picasa_id, auth_token if reload
  @photos ||= photo_class.picasa_find_all user_id, picasa_id, auth_token
end

#picasa_destroyObject

Destroy the current album and returns true. If cannot destroy it, returns false.



188
189
190
191
192
# File 'lib/picasa/album.rb', line 188

def picasa_destroy
  raise_exception? do
    picasa_destroy!
  end
end

#picasa_destroy!Object

Destroy the current album. If cannot destroy it, an exception is raised.



177
178
179
180
181
182
183
# File 'lib/picasa/album.rb', line 177

def picasa_destroy!
  resp, data = Picasa::HTTP::Album.delete_album user_id, self.picasa_id, auth_token
  
  if resp.code != "200" or resp.message != "OK"
    raise Exception, "Error destroying album."
  end
end

#picasa_saveObject

Post an album into Picasa. If cannot create the album returns false.



123
124
125
126
127
# File 'lib/picasa/album.rb', line 123

def picasa_save
  raise_exception? do
    picasa_save!
  end
end

#picasa_save!Object

Post an album into Picasa. If cannot create the album an exception is raised.



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/picasa/album.rb', line 97

def picasa_save!
  if self.picasa_id and picasa_id.length > 0
    return self.picasa_update!
  end
  
  params = {
    :title => title,
    :summary => summary,
    :location => location,
    :keywords => keywords,
    :access => access
  }
  
  resp, data = Picasa::HTTP::Album.post_album(user_id, auth_token, params)
  
  if resp.code != "201" or resp.message != "Created"
    raise Exception, "Error creating album: #{resp.message}."
  end
  
  populate_attributes_from_xml data
  self
end

#picasa_updateObject

Update all attributes of the current album. If cannot update, returns false.



167
168
169
170
171
# File 'lib/picasa/album.rb', line 167

def picasa_update
  raise_exception? do
    picasa_update!
  end
end

#picasa_update!Object

Update all attributes of the current album. If cannot update, an exception is raised.



154
155
156
157
158
159
160
161
162
# File 'lib/picasa/album.rb', line 154

def picasa_update!
  params = {
    :title => title,
    :summary => summary,
    :location => location,
    :keywords => keywords
  }
  picasa_update_attributes! params
end

#picasa_update_attributes(params) ⇒ Object

Update the attributes of the current album. If cannot update, return false.



145
146
147
148
149
# File 'lib/picasa/album.rb', line 145

def picasa_update_attributes params
  raise_exception? do
    picasa_update_attributes! params
  end
end

#picasa_update_attributes!(params) ⇒ Object

Update the attributes of the current album. If cannot update, an exception is raised.



132
133
134
135
136
137
138
139
140
# File 'lib/picasa/album.rb', line 132

def picasa_update_attributes! params
  resp, data = Picasa::HTTP::Album.update_album user_id, self.picasa_id, auth_token, params

  if resp.code != "200" or resp.message != "OK"
    raise Exception, "Error updating album."
  end
  
  populate_attributes_from_xml data
end