Class: Imagebin
Instance Method Summary collapse
- #delete_hash ⇒ Object
- #delete_page ⇒ Object
- #image_hash ⇒ Object
- #imgur_page ⇒ Object
-
#initialize(options) ⇒ Imagebin
constructor
A new instance of Imagebin.
- #large_thumbnail ⇒ Object
- #original_image ⇒ Object
- #small_thumbnail ⇒ Object
Constructor Details
#initialize(options) ⇒ Imagebin
Returns a new instance of Imagebin.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/imagebin.rb', line 12 def initialize() @options = { "image" => "file", "key" => "api_key", } @options.merge!() res = HTTPClient.post('http://imgur.com/api/upload.xml', {:image => File.open(@options['image']), :key => @options['key']}).content @doc = Document.new(res) raise @doc.elements.to_a("//error_msg")[0].text if @doc.elements.to_a("//error_msg").length > 0 end |
Instance Method Details
#delete_hash ⇒ Object
28 29 30 |
# File 'lib/imagebin.rb', line 28 def delete_hash @doc.elements.to_a("//delete_hash")[0].text end |
#delete_page ⇒ Object
48 49 50 |
# File 'lib/imagebin.rb', line 48 def delete_page @doc.elements.to_a("//delete_page")[0].text end |
#image_hash ⇒ Object
24 25 26 |
# File 'lib/imagebin.rb', line 24 def image_hash @doc.elements.to_a("//image_hash")[0].text end |
#imgur_page ⇒ Object
44 45 46 |
# File 'lib/imagebin.rb', line 44 def imgur_page @doc.elements.to_a("//imgur_page")[0].text end |
#large_thumbnail ⇒ Object
36 37 38 |
# File 'lib/imagebin.rb', line 36 def large_thumbnail @doc.elements.to_a("//large_thumbnail")[0].text end |
#original_image ⇒ Object
32 33 34 |
# File 'lib/imagebin.rb', line 32 def original_image @doc.elements.to_a("//original_image")[0].text end |
#small_thumbnail ⇒ Object
40 41 42 |
# File 'lib/imagebin.rb', line 40 def small_thumbnail @doc.elements.to_a("//small_thumbnail")[0].text end |