module Object::ContentType
Public Instance Methods
of(path) → aString or +nil+
click to toggle source
Get the MIME-Type of the file living at path
. Either by looking directly into the file (requires FileMagic), or, assuming path
might denote a URI
, by asking the web server (via OpenURI), or finally by just looking at the file extension (requires MIME::Types). Returns nil
in case no decision could be made.
NOTE: This is really only useful with the filemagic and mime-types gems installed.
# File lib/nuggets/content_type.rb 73 def of(path) 74 ::File.content_type(path) || ::URI.content_type(path) || ( 75 t = ::MIME::Types.of(path).first and t.content_type 76 ) 77 end