Sha256: 7fa9633fef027ae9fdc991f70c0adde490996d19afcef1eea7aab4ea00dac737

Contents?: true

Size: 599 Bytes

Versions: 5

Compression:

Stored size: 599 Bytes

Contents

require 'multi_mime/adapter'

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

5 entries across 5 versions & 1 rubygems

Version Path
multi_mime-1.1.0 lib/multi_mime/adapters/mime_types.rb
multi_mime-1.0.1 lib/multi_mime/adapters/mime_types.rb
multi_mime-1.0 lib/multi_mime/adapters/mime_types.rb
multi_mime-0.0.4 lib/multi_mime/adapters/mime_types.rb
multi_mime-0.0.3 lib/multi_mime/adapters/mime_types.rb