I've seen questions like this on stackoverflow but nothing was for ruby.
So I have file extensions like these:
css
, html
, js
, json
And I want to convert them into:
text/css
, text/html
, text/javascript
, application/json
I want to achieve this in ruby.
So after writing this:
ext_to_mime("css")
I should get:
text/css
If there are any gems for this they are also welcome.
You could use the mime-types
gem:
puts MIME::Types.type_for('css')
=> [text/css]