lib/imgur.rb
# Returns a set of images in gallery format based on your specifications
#
# @param [Hash] params Query string parameters to pass
# @option params [String] :sort Sort order, values are `:latest` or `:popular`
# @option params [String] :view Date limit, values are `:week`, `:month`, or `:all`
# @option params [Integer] :count (20) Number of images to return between 0 and 50
# @option params [Integer] :page (1) Which page of images to display
# @raise [ImgurError]
# @return [Array<Hash>] Array of image data hashes
Returns a set of images in gallery format based on your specifications
Returns a set of images in gallery format based on your specifications
def gallery params = {}
			post_fields = params.collect { |k, v| CGI::escape(k.to_s) + '=' + CGI::escape(v.to_s) }.join('&')
			c = Curl::Easy.new("http://imgur.com/api/gallery.json?#{post_fields}")
			c.http_get
			response = Crack::JSON.parse c.body_str
			raise ImgurError, response["error"]["error_msg"] if response.key?("error")
			response["images"].to_a.collect { |hash, info| info }
		end
def gallery params = { } post_fields = params . collect { | k , v | CGI :: escape ( k . to_s ) + '=' + CGI :: escape ( v . to_s ) } . join ( '&' ) c = Curl :: Easy . new ( "http://imgur.com/api/gallery.json?#{post_fields}" ) c . http_get response = Crack :: JSON . parse c . body_str raise ImgurError , response [ "error" ] [ "error_msg" ] if response . key? ( "error" ) response [ "images" ] . to_a . collect { | hash , info | info } end
Returns a set of images in gallery format based on your specifications
Returns a set of images in gallery format based on your specifications
Array of image data hashes
Array of image data hashes
Array<Hash>
None
params
:page (1) Which page of images to display
: page ( 1 ) Which page of images to display
<not_specific>
params Query string parameters to pass
params Query string parameters to pass