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.
Returns the type of encoding which is required to transport data of this
type safely.
:extensions
[R]
Returns a list of extensions which are known to be used for this MIME type.
:media_type
[R]
Returns the media type of the simplified MIME type. For
text/plain, it will return text.
:simplified
[R]
The MIME types main- and sub-label can both start with x-, which
indicates that it is a non-registered name. Of course, after registration
this flag can disappear which adds to the confusion. The simplified string
has the x- removed and are translated to lowercase.
:sub_type
[R]
Returns the sub-type of the simplified MIME type. For text/plain,
it will return plain.
:system
[R]
Returns the regular expression which can be used to determine whether this
type is active on the system where you are working on.
The MIME types main- and sub-label can both start with x-, which
indicates that it is a non-registered name. Of course, after registration
this flag can disappear which adds to the confusion. The simplified string
has the x- removed and are translated to lowercase.
This constructor takes advantage of a technique for Ruby object
construction introduced by Andy Hunt and Dave Thomas (see reference), where
optional values are set using commands in a block.
Sets the operating system known for a particular MIME content-type. This
value is used to allow for multiple definitions of some MIME content-types,
where the standard extensions and/or encodings are different (e.g.,
text/plain on VMS systems).
arg may also be one of MIME::Type, Array,
or Hash.
MIME content-types which are not regestered by IANA nor defined in RFCs are
required to start with x-. This counts as well for a new media
type as well as a new sub-type of an existing media type. If either the
media-type or the content-type begins with x-, this method will
return false.
MIME types can be specified to be sent across a network in particular
formats. This method returns true when the MIME type encoding is
set to base64 or binary.
Notes:
This is a slightly expanded test to the one defined in the Perl MIME::Type library, as it includes binary.
MIME types can be specified to be sent across a network in particular
formats. This method returns false when the MIME type encoding is
set to base64 or binary.
Notes:
This is a slightly different test than the one defined in the Perl MIME::Type library, as it is merely a reverse of binary?.
Sets the operating system known for a particular MIME content-type. This
value is used to allow for multiple definitions of some MIME content-types,
where the standard extensions and/or encodings are different (e.g.,
text/plain on VMS systems). Only works in constructor block.