Class: SnipSnap::Image
- Inherits:
-
Object
- Object
- SnipSnap::Image
- Includes:
- Client
- Defined in:
- lib/snip_snap/image.rb
Constant Summary collapse
- MIME_TYPES =
%w(image/jpeg image/gif image/pjpeg image/png)
- EXTENSIONS =
%w(jpeg jpg gif png)
Instance Method Summary collapse
Methods included from Client
Instance Method Details
#extension ⇒ Object
15 16 17 18 19 20 |
# File 'lib/snip_snap/image.rb', line 15 def extension uri = URI.parse(response.last_effective_url) extension = File.extname(uri.path).sub(/./, '') extension unless extension == '' end |
#image? ⇒ Boolean
22 23 24 |
# File 'lib/snip_snap/image.rb', line 22 def image? MIME_TYPES.include?(mime_type) || EXTENSIONS.include?(extension) end |
#image_url ⇒ Object
26 27 28 |
# File 'lib/snip_snap/image.rb', line 26 def image_url response.last_effective_url if image? end |
#mime_type ⇒ Object
11 12 13 |
# File 'lib/snip_snap/image.rb', line 11 def mime_type response.content_type end |