class Imgurapi::FileType

Constants

GIF
JPG
JPG2
PNG

Public Class Methods

new(path) click to toggle source
# File lib/imgurapi/file_type.rb, line 9
def initialize(path)
  @path = path
end

Public Instance Methods

image?() click to toggle source
# File lib/imgurapi/file_type.rb, line 26
def image?
  !!mime_type
end
mime_type() click to toggle source
# File lib/imgurapi/file_type.rb, line 13
def mime_type
  case IO.read(@path, 10)
  when GIF
    'image/gif'
  when PNG
    'image/png'
  when JPG
    'image/jpeg'
  when JPG2
    'image/jpeg'
  end
end
url?() click to toggle source
# File lib/imgurapi/file_type.rb, line 30
def url?
  !!(@path =~ %r(^(http://|https://|ftp://)))
end