Class: Imgur::Album
- Inherits:
-
Object
- Object
- Imgur::Album
- Defined in:
- lib/imgur.rb
Instance Attribute Summary collapse
-
#account_url ⇒ Object
Returns the value of attribute account_url.
-
#cover ⇒ Object
Returns the value of attribute cover.
-
#cover_height ⇒ Object
Returns the value of attribute cover_height.
-
#cover_width ⇒ Object
Returns the value of attribute cover_width.
-
#date ⇒ Object
Returns the value of attribute date.
-
#deletehash ⇒ Object
Returns the value of attribute deletehash.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#images ⇒ Object
Returns the value of attribute images.
-
#images_count ⇒ Object
Returns the value of attribute images_count.
-
#layout ⇒ Object
Returns the value of attribute layout.
-
#link ⇒ Object
Returns the value of attribute link.
-
#privacy ⇒ Object
Returns the value of attribute privacy.
-
#title ⇒ Object
Returns the value of attribute title.
-
#views ⇒ Object
Returns the value of attribute views.
Instance Method Summary collapse
-
#initialize(data) ⇒ Album
constructor
A new instance of Album.
- #update(client) ⇒ Object
Constructor Details
#initialize(data) ⇒ Album
Returns a new instance of Album.
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/imgur.rb', line 169 def initialize(data) @id = data['id'] @title = data['title'] @description = data['description'] @date = Time.at data['datetime'] @cover = data['cover'] @cover_width = data['cover_width'] @account_url = data['account_url'] @privacy = data['privacy'] @layout = data['layout'] @views = data['views'] @link = data['link'] @deletehash = data['deletehash'] @images_count = data['images_count'] @images = [] data['images'].each do |img| @images << Image.new(img) end end |
Instance Attribute Details
#account_url ⇒ Object
Returns the value of attribute account_url.
165 166 167 |
# File 'lib/imgur.rb', line 165 def account_url @account_url end |
#cover ⇒ Object
Returns the value of attribute cover.
165 166 167 |
# File 'lib/imgur.rb', line 165 def cover @cover end |
#cover_height ⇒ Object
Returns the value of attribute cover_height.
165 166 167 |
# File 'lib/imgur.rb', line 165 def cover_height @cover_height end |
#cover_width ⇒ Object
Returns the value of attribute cover_width.
165 166 167 |
# File 'lib/imgur.rb', line 165 def cover_width @cover_width end |
#date ⇒ Object
Returns the value of attribute date.
165 166 167 |
# File 'lib/imgur.rb', line 165 def date @date end |
#deletehash ⇒ Object
Returns the value of attribute deletehash.
165 166 167 |
# File 'lib/imgur.rb', line 165 def deletehash @deletehash end |
#description ⇒ Object
Returns the value of attribute description.
165 166 167 |
# File 'lib/imgur.rb', line 165 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
165 166 167 |
# File 'lib/imgur.rb', line 165 def id @id end |
#images ⇒ Object
Returns the value of attribute images.
165 166 167 |
# File 'lib/imgur.rb', line 165 def images @images end |
#images_count ⇒ Object
Returns the value of attribute images_count.
165 166 167 |
# File 'lib/imgur.rb', line 165 def images_count @images_count end |
#layout ⇒ Object
Returns the value of attribute layout.
165 166 167 |
# File 'lib/imgur.rb', line 165 def layout @layout end |
#link ⇒ Object
Returns the value of attribute link.
165 166 167 |
# File 'lib/imgur.rb', line 165 def link @link end |
#privacy ⇒ Object
Returns the value of attribute privacy.
165 166 167 |
# File 'lib/imgur.rb', line 165 def privacy @privacy end |
#title ⇒ Object
Returns the value of attribute title.
165 166 167 |
# File 'lib/imgur.rb', line 165 def title @title end |
#views ⇒ Object
Returns the value of attribute views.
165 166 167 |
# File 'lib/imgur.rb', line 165 def views @views end |
Instance Method Details
#update(client) ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/imgur.rb', line 189 def update(client) if @deletehash == nil raise UpdateException.new 'Album must have a deletehash to update' end url = API_PATH + ALBUM_GET_PATH + @deletehash image_ids = [] # Make sure we're only strings @images.each do |img| if img.is_a? Image image_ids << img.id elsif img.is_a? String image_ids << img end end body = { ids: @images, title: @title, description: @description, privacy: @privacy, layout: @layout, cover: @cover } puts body client.post(url, body: body) end |