Module: Qeweney::MimeTypes
- Defined in:
- lib/qeweney/mime_types.rb
Overview
File extension to MIME type mapping
Constant Summary collapse
- TYPES =
{ 'html' => 'text/html', 'css' => 'text/css', 'js' => 'application/javascript', 'txt' => 'text/plain', 'text' => 'text/plain', 'gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'png' => 'image/png', 'ico' => 'image/x-icon', 'pdf' => 'application/pdf', 'json' => 'application/json', }.freeze
- EXT_REGEXP =
/\.?([^\.]+)$/.freeze
Class Method Summary collapse
Class Method Details
.[](ref) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/qeweney/mime_types.rb', line 25 def self.[](ref) case ref when Symbol TYPES[ref.to_s] when EXT_REGEXP TYPES[Regexp.last_match(1)] when '' nil else raise "Invalid argument #{ref.inspect}" end end |