Class: MiniMime::Db
- Inherits:
-
Object
show all
- Defined in:
- lib/mini_mime.rb
Defined Under Namespace
Classes: Cache, RandomAccessDb
Constant Summary
collapse
- LOCK =
Mutex.new
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Db
Returns a new instance of Db.
Class Method Details
.lookup_by_content_type(content_type) ⇒ Object
69
70
71
72
73
74
|
# File 'lib/mini_mime.rb', line 69
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) ⇒ Object
62
63
64
65
66
67
|
# File 'lib/mini_mime.rb', line 62
def self.lookup_by_extension(extension)
LOCK.synchronize do
@db ||= new
@db.lookup_by_extension(extension)
end
end
|
.lookup_by_filename(filename) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/mini_mime.rb', line 54
def self.lookup_by_filename(filename)
extension = File.extname(filename)
return if extension.empty?
extension = extension[1..-1]
extension.downcase!
lookup_by_extension(extension)
end
|
Instance Method Details
#lookup_by_content_type(content_type) ⇒ Object
162
163
164
|
# File 'lib/mini_mime.rb', line 162
def lookup_by_content_type(content_type)
@content_type_db.lookup(content_type)
end
|
#lookup_by_extension(extension) ⇒ Object
158
159
160
|
# File 'lib/mini_mime.rb', line 158
def lookup_by_extension(extension)
@ext_db.lookup(extension)
end
|