class MiniMime::Db
Constants
- LOCK
Public Class Methods
lookup_by_content_type(content_type)
click to toggle source
# File lib/mini_mime.rb, line 56 def self.lookup_by_content_type(content_type) LOCK.synchronize do @db ||= new @db.lookup_by_content_type(content_type) end end
lookup_by_filename(filename)
click to toggle source
# File lib/mini_mime.rb, line 40 def self.lookup_by_filename(filename) extension = File.extname(filename) if extension extension.sub!(".", "") extension.downcase! if extension.length > 0 LOCK.synchronize do @db ||= new @db.lookup_by_extension(extension) end else nil end end end
new()
click to toggle source
# File lib/mini_mime.rb, line 140 def initialize @ext_db = RandomAccessDb.new("ext_mime.db", 0) @content_type_db = RandomAccessDb.new("content_type_mime.db", 1) end
Public Instance Methods
lookup_by_content_type(content_type)
click to toggle source
# File lib/mini_mime.rb, line 149 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 145 def lookup_by_extension(extension) @ext_db.lookup(extension) end