- home
- code
- bugs
- rdoc
- code climate
-
<img src=“https://codeclimate.com/github/halostatue/mime-types.png” />
- continuous integration
-
<img src=“https://travis-ci.org/halostatue/mime-types.png” />
This library allows for the identification of a file’s likely MIME content type. This is release 1.23 that adds the ability to enumerate over the collection of MIME types and updates the sources of a few MIME types. The identification of MIME content type is based on a file’s filename extensions.
MIME types are used in MIME-compliant communications, as in e-mail or HTTP traffic, to indicate the type of content which is transmitted. MIME::Types provides the ability for detailed information about MIME entities (provided as a set of MIME::Type objects) to be determined and used programmatically. There are many types defined by RFCs and vendors, so the list is long but not complete; don’t hesitate to ask to add additional information. This library follows the IANA collection of MIME types (see below for reference).
MIME::Types for Ruby was originally based on MIME::Types for Perl by Mark Overmeer, copyright 2001 - 2009. As of version 1.15, the data format for the MIME::Type list has changed and the synchronization will no longer happen.
MIME::Types is built to conform to the MIME types of RFCs 2045 and 2231. It tracks the IANA registry (ftp) with some unofficial types added from the LTSW collection and added by the users of MIME::Types.
MIME types are used in MIME entities, as in email or HTTP traffic. It is useful at times to have information available about MIME types (or, inversely, about files). A MIME::Type stores the known information about one MIME type.
require 'mime/types' plaintext = MIME::Types['text/plain'] # returns [text/plain, text/plan] text = plaintext.first puts text.media_type # => 'text' puts text.sub_type # => 'plain' puts text.extensions.join(" ") # => 'txt asc c cc h hh cpp hpp dat hlp' puts text.encoding # => quoted-printable puts text.binary? # => false puts text.ascii? # => true puts text.obsolete? # => false puts text.registered? # => true puts text == 'text/plain' # => true puts MIME::Type.simplified('x-appl/x-zip') # => 'appl/zip' puts MIME::Types.any? { |type| type.content_type == 'text/plain' } # => true puts MIME::Types.all?(&:registered?) # => false
:include: Contributing.rdoc
:include: Licence.rdoc