Class: ImgurGateway
- Inherits:
-
Object
- Object
- ImgurGateway
- Defined in:
- lib/imgur_gateway.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(filename: nil, title: nil) ⇒ ImgurGateway
constructor
A new instance of ImgurGateway.
- #upload ⇒ Object
Constructor Details
#initialize(filename: nil, title: nil) ⇒ ImgurGateway
Returns a new instance of ImgurGateway.
7 8 9 10 |
# File 'lib/imgur_gateway.rb', line 7 def initialize(filename: nil, title: nil) @filename = filename @title = title || image_title end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
5 6 7 |
# File 'lib/imgur_gateway.rb', line 5 def filename @filename end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/imgur_gateway.rb', line 5 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/imgur_gateway.rb', line 5 def url @url end |
Instance Method Details
#upload ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/imgur_gateway.rb', line 12 def upload return false unless filename client = Imgur.new(imgur_api_key) image = Imgur::LocalImage.new(filename, title: title) uploaded = client.upload(image) @url = uploaded.link rescue Exception => e puts "Error uploading to imgur #{e}" return false end |