Class: Diamant::MimeType

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_typeObject (readonly)

Returns the value of attribute content_type.



8
9
10
# File 'lib/diamant/mimetype.rb', line 8

def content_type
  @content_type
end

#extensionObject (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

Returns:

  • (Boolean)


28
29
30
# File 'lib/diamant/mimetype.rb', line 28

def supported?
  @extension != '' && MIMETYPES.has_key?(@extension)
end