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.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/imagebin.rb', line 11 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 begin @doc = Document.new(res) rescue res[/<h1>(.*)<\/h1>/] puts $1 exit end 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
33 34 35 |
# File 'lib/imagebin.rb', line 33 def delete_hash @doc.elements.to_a("//delete_hash")[0].text end |
#delete_page ⇒ Object
53 54 55 |
# File 'lib/imagebin.rb', line 53 def delete_page @doc.elements.to_a("//delete_page")[0].text end |
#image_hash ⇒ Object
29 30 31 |
# File 'lib/imagebin.rb', line 29 def image_hash @doc.elements.to_a("//image_hash")[0].text end |
#imgur_page ⇒ Object
49 50 51 |
# File 'lib/imagebin.rb', line 49 def imgur_page @doc.elements.to_a("//imgur_page")[0].text end |
#large_thumbnail ⇒ Object
41 42 43 |
# File 'lib/imagebin.rb', line 41 def large_thumbnail @doc.elements.to_a("//large_thumbnail")[0].text end |
#original_image ⇒ Object
37 38 39 |
# File 'lib/imagebin.rb', line 37 def original_image @doc.elements.to_a("//original_image")[0].text end |
#small_thumbnail ⇒ Object
45 46 47 |
# File 'lib/imagebin.rb', line 45 def small_thumbnail @doc.elements.to_a("//small_thumbnail")[0].text end |