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
70
71
72
73
74
75
|
# 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) ⇒ Object
62
63
64
65
66
67
68
|
# 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) ⇒ Object
55
56
57
58
59
60
|
# 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
|
Instance Method Details
#lookup_by_content_type(content_type) ⇒ Object
163
164
165
|
# 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) ⇒ Object
159
160
161
|
# File 'lib/mini_mime.rb', line 159
def lookup_by_extension(extension)
@ext_db.lookup(extension)
end
|