Class: Assets::Mime

Inherits:
Object
  • Object
show all
Includes:
Adamantium
Defined in:
lib/assets/mime.rb

Overview

Mime type for assets

Constant Summary collapse

REGISTRY =
{}
JPG =
new('.jpg',    'image/jpeg'                              )
ICO =
new('.ico',    'image/vnd.microsoft.icon'                )
PNG =
new('.png',    'image/png'                               )
GIF =
new('.gif',    'image/gif'                               )
SVG =
new('.svg',    'image/svg'                               )
PDF =
new('.pdf',    'application/pdf'                         )
RUBY =
new('.rb',     'application/ruby'                        )
TXT =
new('.txt',    'text/plain; charset=UTF-8'               )
CSS =
new('.css',    'text/css; charset=UTF-8'                 )
JAVASCRIPT =
new('.js',     'application/javascript; charset=UTF-8'   )
COFFEESCRIPT =
new('.coffee', 'application/coffeescript; charset=UTF-8' )
SASS =
new('.sass',   'text/plain; charset=UTF-8'               )
SCSS =
new('.scss',   'text/plain; charset=UTF-8'               )
HTML =
new('.html',   'text/html; charset=UTF-8'                )
WOFF =
new('.woff',   'application/font-woff'                   )
EOT =
new('.eot',    'application/vnd.ms-fontobject'           )
IMAGES =
[
  JPG, ICO, PNG, SVG, GIF
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#content_typeString (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return content type

Returns:

  • (String)


22
23
24
# File 'lib/assets/mime.rb', line 22

def content_type
  @content_type
end

#extnameString (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return extname

Returns:

  • (String)


14
15
16
# File 'lib/assets/mime.rb', line 14

def extname
  @extname
end

Class Method Details

.extname(extname) ⇒ Mime

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return mime for extname

Parameters:

  • extname (String)

Returns:



32
33
34
# File 'lib/assets/mime.rb', line 32

def self.extname(extname)
  REGISTRY.fetch(extname)
end

.from_name(name) ⇒ Mime

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return mime name

Parameters:

  • name (String)

Returns:



44
45
46
# File 'lib/assets/mime.rb', line 44

def self.from_name(name)
  extname(::File.extname(name))
end