Sha256: 948af50a3cccfa54913c09ecf0dcef36a733f68bee31e46054cfbee09b91412d
Contents?: true
Size: 1.09 KB
Versions: 3
Compression:
Stored size: 1.09 KB
Contents
module Imgur module Api class Image < Base # https://api.imgur.com/endpoints/image#image def image(id) raise 'Please provide a valid image identificator' if id.nil? or !id.kind_of? String or id == '' or !!(id =~ /[^\w]/) Imgur::Image.new communication.call(:get, "image/#{id}") end # https://api.imgur.com/endpoints/image#image-upload def image_upload(local_file) if local_file.kind_of? String file = File.open(local_file, 'rb') elsif local_file.respond_to? :read file = local_file else raise 'Must provide a File or file path' end Imgur::Image.new communication.call(:post, 'image', image: Base64.encode64(file.read)) end # https://api.imgur.com/endpoints/image#image-delete def image_delete(id) if id.kind_of? Imgur::Image id = id.id end raise 'Please provide a valid image identificator' if id.nil? or !id.kind_of? String or id == '' or !!(id =~ /[^\w]/) communication.call(:delete, "image/#{id}") end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
imgurapi-2.0.2 | lib/imgur/api/image.rb |
imgurapi-2.0.1 | lib/imgur/api/image.rb |
imgurapi-2.0.0 | lib/imgur/api/image.rb |