Class: Imgur::Client::Images

Inherits:
Cistern::Collection
  • Object
show all
Includes:
Imgur::Collection, PagedCollection
Defined in:
lib/imgur/models/images.rb

Instance Method Summary collapse

Methods included from Imgur::Collection

#get, included, #model_request, #model_root

Methods included from PagedCollection

#==, #collection_request, #collection_root, included, #last_page, #next_page, #previous_page

Instance Method Details

#all(options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/imgur/models/images.rb', line 13

def all(options={})
  path = ""
  path = path + "/#{options[:resource] || "gallery"}"
  if options[:section]
    path = path + "/#{options[:section]}"
  elsif options[:subreddit]
    path = path + "/r/#{options[:subreddit]}"
  end
  path = path + "/#{options[:sort]}" if options[:sort]
  path = path + "/#{options[:page] || 0}.json"

  data = connection.get_images(path: path).body["data"]
  connection.images.load(data)
end