Class: MimeTable
- Inherits:
-
Object
- Object
- MimeTable
- Defined in:
- lib/mime_table.rb
Overview
This module is intended to be a lightweight substitute for the ActionPack Mime::Type module provided with Rails. It should be used for mime type lookups only and is not a full replacement for Mime::Type.
Defined Under Namespace
Classes: MimeType
Constant Summary collapse
- @@types =
[]
Class Method Summary collapse
Class Method Details
.lookup_by_extension(ext) ⇒ Object
16 17 18 19 |
# File 'lib/mime_table.rb', line 16 def lookup_by_extension(ext) ext = ext.gsub(/^\./, "").to_sym if ext.is_a?(String) MimeType.new(@@types.select {|t| t[:extension] == ext }.first) end |
.register(content_type, extension) ⇒ Object
12 13 14 |
# File 'lib/mime_table.rb', line 12 def register(content_type, extension) @@types << {:content_type => content_type, :extension => extension} end |