Class: Imgur::Album

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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_urlObject

Returns the value of attribute account_url.



165
166
167
# File 'lib/imgur.rb', line 165

def 
  @account_url
end

#coverObject

Returns the value of attribute cover.



165
166
167
# File 'lib/imgur.rb', line 165

def cover
  @cover
end

#cover_heightObject

Returns the value of attribute cover_height.



165
166
167
# File 'lib/imgur.rb', line 165

def cover_height
  @cover_height
end

#cover_widthObject

Returns the value of attribute cover_width.



165
166
167
# File 'lib/imgur.rb', line 165

def cover_width
  @cover_width
end

#dateObject

Returns the value of attribute date.



165
166
167
# File 'lib/imgur.rb', line 165

def date
  @date
end

#deletehashObject

Returns the value of attribute deletehash.



165
166
167
# File 'lib/imgur.rb', line 165

def deletehash
  @deletehash
end

#descriptionObject

Returns the value of attribute description.



165
166
167
# File 'lib/imgur.rb', line 165

def description
  @description
end

#idObject

Returns the value of attribute id.



165
166
167
# File 'lib/imgur.rb', line 165

def id
  @id
end

#imagesObject

Returns the value of attribute images.



165
166
167
# File 'lib/imgur.rb', line 165

def images
  @images
end

#images_countObject

Returns the value of attribute images_count.



165
166
167
# File 'lib/imgur.rb', line 165

def images_count
  @images_count
end

#layoutObject

Returns the value of attribute layout.



165
166
167
# File 'lib/imgur.rb', line 165

def layout
  @layout
end

Returns the value of attribute link.



165
166
167
# File 'lib/imgur.rb', line 165

def link
  @link
end

#privacyObject

Returns the value of attribute privacy.



165
166
167
# File 'lib/imgur.rb', line 165

def privacy
  @privacy
end

#titleObject

Returns the value of attribute title.



165
166
167
# File 'lib/imgur.rb', line 165

def title
  @title
end

#viewsObject

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