Skip to content

Commit

Permalink
Fixing a documentation error.
Browse files Browse the repository at this point in the history
  • Loading branch information
halostatue committed May 4, 2013
1 parent be28c7f commit 102a180
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
5 changes: 5 additions & 0 deletions History.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
* Working on improving the quality of the mime-types codebase through the use
of Code Climate. https://codeclimate.com/github/halostatue/mime-types
* Simplified MIME::Type.from_array to make more assumptions about assignment.
* Documentation:
* LeoYoung <[email protected]> pointed out that the README.rdoc contained
examples that could never possibly work because MIME::Types#[] returns (for
all the versions I have handy) an array, not a single type. I have updated
README.rdoc to reflect this.

== 1.23 / 2013-04-20

Expand Down
41 changes: 24 additions & 17 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ 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 and synchronized with 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 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
follows the official {IANA registry}[http://www.iana.org/assignments/media-types/]
tracks the {IANA registry}[http://www.iana.org/assignments/media-types/]
({ftp}[ftp://ftp.iana.org/assignments/media-types]) with some unofficial types
added from the the {LTSW collection}[http://www.ltsw.se/knbase/internet/mime.htp].
added from the {LTSW collection}[http://www.ltsw.se/knbase/internet/mime.htp]
and added by the users of MIME::Types.

== Synopsis

Expand All @@ -41,20 +41,27 @@ files). A MIME::Type stores the known information about one MIME type.
require 'mime/types'

plaintext = MIME::Types['text/plain']
print plaintext.media_type # => 'text'
print plaintext.sub_type # => 'plain'
# returns [text/plain, text/plan]
text = plaintext.first
puts text.media_type # => 'text'
puts text.sub_type # => 'plain'

puts plaintext.extensions.join(" ") # => 'asc txt c cc h hh cpp'
puts text.extensions.join(" ") # => 'txt asc c cc h hh cpp hpp dat hlp'

puts plaintext.encoding # => 8bit
puts plaintext.binary? # => false
puts plaintext.ascii? # => true
puts plaintext.obsolete? # => false
puts plaintext.registered? # => true
puts plaintext == 'text/plain' # => true
puts MIME::Type.simplified('x-appl/x-zip') # => 'appl/zip'
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' }
puts MIME::Types.any? { |type|
type.content_type == 'text/plain'
} # => true
puts MIME::Types.all?(&:registered?)
# => false

:include: Contributing.rdoc

Expand Down

0 comments on commit 102a180

Please sign in to comment.