Class: Imagebin
- Inherits:
-
Object
- Object
- Imagebin
- Defined in:
- lib/imagebin.rb
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 |
# File 'lib/imagebin.rb', line 11 def initialize() @options = { "image" => "file", "key" => "api_key", } @options.merge!() File.open(@options["image"]) do |file| @options["image"] = file clnt = HTTPClient.new res = clnt.post('http://imgur.com/api/upload.xml', @options).content @doc = Hpricot(res) raise @doc.at('error_msg').innerHTML if @doc.at('error_msg') != nil end end |
Instance Method Details
#delete_hash ⇒ Object
29 30 31 |
# File 'lib/imagebin.rb', line 29 def delete_hash @doc.at('delete_hash').innerHTML end |
#delete_page ⇒ Object
49 50 51 |
# File 'lib/imagebin.rb', line 49 def delete_page @doc.at('delete_page').innerHTML end |
#image_hash ⇒ Object
25 26 27 |
# File 'lib/imagebin.rb', line 25 def image_hash @doc.at('image_hash').innerHTML end |
#imgur_page ⇒ Object
45 46 47 |
# File 'lib/imagebin.rb', line 45 def imgur_page @doc.at('imgur_page').innerHTML end |
#large_thumbnail ⇒ Object
37 38 39 |
# File 'lib/imagebin.rb', line 37 def large_thumbnail @doc.at('large_thumbnail').innerHTML end |
#original_image ⇒ Object
33 34 35 |
# File 'lib/imagebin.rb', line 33 def original_image @doc.at("original_image").innerHTML end |
#small_thumbnail ⇒ Object
41 42 43 |
# File 'lib/imagebin.rb', line 41 def small_thumbnail @doc.at('small_thumbnail').innerHTML end |