Content::Type
RFC-compliant Content-Type parser.
Installation
Add this line to your application's Gemfile:
gem 'content-type'
And then execute:
$ bundle
Or install it yourself as:
$ gem install content-type
Usage
content_type = ContentType.parse "application/JSON; charset=utf-8; foo=bar"
content_type.mime_type # => "application/json"
content_type.type # => "application"
content_type.subtype # => "json"
content_type.charset # => "utf-8"
content_type.parameters["charset"] # => "utf-8"
content_type.parameters["foo"] # => "bar"
Contributing
- Fork it ( http://github.com/
/content-type/fork ) - Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request