class MiniMime::Db

Constants

LOCK

Public Class Methods

lookup_by_content_type(content_type) click to toggle source
# File lib/mini_mime.rb, line 70
def self.lookup_by_content_type(content_type)
  LOCK.synchronize do
    @db ||= new
    @db.lookup_by_content_type(content_type)
  end
end
lookup_by_extension(extension) click to toggle source
# File lib/mini_mime.rb, line 62
def self.lookup_by_extension(extension)
  LOCK.synchronize do
    @db ||= new
    @db.lookup_by_extension(extension) ||
      @db.lookup_by_extension(extension.downcase)
  end
end
lookup_by_filename(filename) click to toggle source
# File lib/mini_mime.rb, line 55
def self.lookup_by_filename(filename)
  extension = File.extname(filename)
  return if extension.empty?
  extension = extension[1..-1]
  lookup_by_extension(extension)
end
new() click to toggle source
# File lib/mini_mime.rb, line 154
def initialize
  @ext_db = RandomAccessDb.new(Configuration.ext_db_path, 0)
  @content_type_db = RandomAccessDb.new(Configuration.content_type_db_path, 1)
end

Public Instance Methods

lookup_by_content_type(content_type) click to toggle source
# File lib/mini_mime.rb, line 163
def lookup_by_content_type(content_type)
  @content_type_db.lookup(content_type)
end
lookup_by_extension(extension) click to toggle source
# File lib/mini_mime.rb, line 159
def lookup_by_extension(extension)
  @ext_db.lookup(extension)
end