Sha256: 9a801261e06fc3843b8e3aa2ac69641056c467e8e8e79da605ec5fcf3fbbc600
Contents?: true
Size: 875 Bytes
Versions: 3
Compression:
Stored size: 875 Bytes
Contents
module FontAssets class MimeTypes DEFAULT_TYPE = 'application/octet-stream' MIME_TYPES = { '.eot' => 'application/vnd.ms-fontobject', '.svg' => 'image/svg+xml', '.ttf' => 'application/x-font-ttf', '.woff' => 'application/x-font-woff' } def initialize(types, default = DEFAULT_TYPE.dup) @types = types.dup @default = default MIME_TYPES.each_pair do |extension, type| set extension, type end end def [](extension) @types.fetch(extension, DEFAULT_TYPE.dup).dup end def font?(extension) MIME_TYPES.keys.include? extension end def set(extension, mime_type) if @types[extension].nil? || @types[extension] == @default set!(extension, mime_type) end end def set!(extension, mime_type) @types[extension] = mime_type end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
font_assets-0.1.2 | lib/font_assets/mime_types.rb |
font_assets-0.1.1 | lib/font_assets/mime_types.rb |
font_assets-0.1.0 | lib/font_assets/mime_types.rb |