Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding mime_type method #76

Conversation

stephan-nordnes-eriksen

Adds a simple way to get the mime type of an object. I feel this particular feature is an important one, but is missing.

Adds a simple way to get the mime type of an object.
@halostatue
Copy link
Member

This already exists in two separate methods (that provide slightly different things): #content_type (returning the raw content type) and #simplified (returning the nearest “true” MIME type):

q = MIME::Type.new('text/x-plain')
q.content_type # => 'text/x-plain'
q.simplified # => 'text/plain'

The #to_s method also returns the #content_type. Your version is essentially the same things as #simplified (whereas #content_type would be using #raw_media_type and #raw_sub_type). I don’t think that I’d want a patch for a method #mime_type that returns the same as #simplified—because it isn’t clear whether you would want the original type or the simplified type, but I would happily accept a patch or issue that suggests a place that I can clean up the documentation around these methods.

What’s the context you wanted to use this in, such that #content_type and #simplified weren’t what you found?

@halostatue halostatue added this to the 2.5 milestone Oct 19, 2014
@halostatue halostatue self-assigned this Oct 19, 2014
@stephan-nordnes-eriksen
Copy link
Author

Alright, I see. I do agree the method name "mime_type" can be a bit confusing. Well, at least I think something should be done to the docs, because I was unable to figure out how to get a simple string representation of the mime type by glancing at the readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants