Sha256: c463bc7dd9917cc382f6f800d14d25b8b0980f81ba1dee74a225e236edd1de16

Contents?: true

Size: 709 Bytes

Versions: 1

Compression:

Stored size: 709 Bytes

Contents

require "mime/types" unless defined?(::MIME::Types)
require "multi_mime/adapter"
require "multi_mime/null_type"

module MultiMime
  module Adapters

    # Use the MIME::Types library
    class MimeTypes < Adapter

      #
      def type_for(mime_type, opts={})
        ::MIME::Types[mime_type].first || MultiMime::NullType.new
      end

      #
      def type_for_extension(extension, opts={})
        ::MIME::Types.type_for(extension).first || MultiMime::NullType.new
      end

      #
      def type_for_path(path, opts={})
        type_for_extension(File.extname(path))
      end

      #
      def type_for_file(file, opts={})
        type_for_extension(File.extname(file))
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multi_mime-0.0.2 lib/multi_mime/adapters/mime_types.rb