Class: Imgur::Image
Constant Summary collapse
- IMAGE_URL =
'http://i.imgur.com/'
- IMAGE_EXTENSION =
jpg is the default extension for every Imgur image
'jpg'
Instance Method Summary collapse
- #link ⇒ Object
-
#url(size) ⇒ Object
Provides the download URL in case you know a valid imgur hash and don’t want to make a network trip with .find Just in case you don’t need the full Imgur::Image object.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Imgur::Base
Instance Method Details
#link ⇒ Object
7 8 9 |
# File 'lib/imgur/models/image.rb', line 7 def link @link ||= "#{IMAGE_URL}#{id}.#{IMAGE_EXTENSION}" end |
#url(size) ⇒ Object
Provides the download URL in case you know a valid imgur hash and don’t want to make a network trip with .find Just in case you don’t need the full Imgur::Image object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/imgur/models/image.rb', line 13 def url(size) size = case size when :small_square, :small, :s 's' when :large_thumbnail, :large, :l 'l' else '' end splitted_link = link.split('.') splitted_link[splitted_link.size - 2] << size splitted_link.join '.' end |