class Diamant::MimeType

Helper to understand what mimetype has a given file

Constants

MIMETYPES

Attributes

content_type[R]
extension[R]

Public Class Methods

new(path) click to toggle source
# File lib/diamant/mimetype.rb, line 23
def initialize(path)
  @path = path
  extract_info
end

Public Instance Methods

supported?() click to toggle source
# File lib/diamant/mimetype.rb, line 28
def supported?
  @extension != '' && MIMETYPES.has_key?(@extension)
end

Private Instance Methods

extract_info() click to toggle source
# File lib/diamant/mimetype.rb, line 34
def extract_info
  @extension = File.extname @path
  raise MimeError, "#{@path} format is not supported!" unless supported?
  # Any other supported extension
  @content_type = MIMETYPES[@extension]
end