Class: Diamant::MimeType
- Inherits:
-
Object
- Object
- Diamant::MimeType
- Defined in:
- lib/diamant/mimetype.rb
Overview
Helper to understand what mimetype has a given file
Constant Summary collapse
- MIMETYPES =
{ '.gemini' => 'text/gemini', '.gmi' => 'text/gemini', '.txt' => 'text/plain', '.md' => 'text/markdown', '.org' => 'text/org', '.xml' => 'application/xml', '.png' => 'image/png', '.jpg' => 'image/jpeg', '.jpeg' => 'image/jpeg', '.gif' => 'image/gif' }.freeze
Instance Attribute Summary collapse
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#extension ⇒ Object
readonly
Returns the value of attribute extension.
Instance Method Summary collapse
-
#initialize(path) ⇒ MimeType
constructor
A new instance of MimeType.
- #supported? ⇒ Boolean
Constructor Details
#initialize(path) ⇒ MimeType
Returns a new instance of MimeType.
23 24 25 26 |
# File 'lib/diamant/mimetype.rb', line 23 def initialize(path) @path = path extract_info end |
Instance Attribute Details
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
8 9 10 |
# File 'lib/diamant/mimetype.rb', line 8 def content_type @content_type end |
#extension ⇒ Object (readonly)
Returns the value of attribute extension.
8 9 10 |
# File 'lib/diamant/mimetype.rb', line 8 def extension @extension end |
Instance Method Details
#supported? ⇒ Boolean
28 29 30 |
# File 'lib/diamant/mimetype.rb', line 28 def supported? @extension != '' && MIMETYPES.has_key?(@extension) end |