class Friendly::MIME

Constants

VERSION

Attributes

mimes[RW]

Public Class Methods

find(mime) click to toggle source

Finds MIME friendly name by extension or MIME type

@example

Friendly::MIME.find 'application/zip'

or

Friendly::MIME.find '.zip'
# File lib/friendly_mime.rb, line 29
def find(mime)
  return nil if mime.nil?
  self.mimes[mime.to_s.downcase]
end
load() click to toggle source

Loads all mime names and extensions to a memory

# File lib/friendly_mime.rb, line 12
def load
  self.mimes = {}
  CSV.foreach(File.expand_path(File.join(File.dirname(__FILE__), '..', 'mimes.csv')), :headers => false) do |row|
    self.mimes[row[0]] = row[1]
    self.mimes[row[2]] = row[1]
  end
end