Class: Web::Mime
Overview
Purpose
This class returns mime types. It parses an apache-style mime.types file located in site_lib/web/resources/mime.types for it’s database.
This class can be independantly of the rest of NARF:
require 'web/mime.rb'
Web::Mime::get_mime_type( 'filename.txt' )
Defined Under Namespace
Classes: ApacheUnixReader
Constant Summary collapse
- DEFAULT_MIMETYPE =
"text/html"
- @@readers =
[]
- @@mime_types =
nil
Class Method Summary collapse
- .clear ⇒ Object
- .get_mime_type(filename) ⇒ Object (also: get_mimetype)
- .mime_types ⇒ Object
- .readers ⇒ Object
Class Method Details
.clear ⇒ Object
57 58 59 |
# File 'lib/web/mime.rb', line 57 def clear @@mime_types = nil end |
.get_mime_type(filename) ⇒ Object Also known as: get_mimetype
73 74 75 |
# File 'lib/web/mime.rb', line 73 def get_mime_type( filename ) mime_types[filename.split(".").last].to_s end |
.mime_types ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/web/mime.rb', line 61 def mime_types unless(@@mime_types) readers.each{ |klass| if klass.applies? @@mime_types = klass.new.mime_types break end } end @@mime_types end |