Module: Nuggets::URI::ContentTypeMixin

Included in:
URI
Defined in:
lib/nuggets/uri/content_type_mixin.rb

Instance Method Summary collapse

Instance Method Details

#content_type(uri) ⇒ Object

call-seq:

URI.content_type(uri) => aString or nil

Return the content type of uri, or nil if not found.



39
40
41
42
43
# File 'lib/nuggets/uri/content_type_mixin.rb', line 39

def content_type(uri)
  open(uri.to_s).content_type
rescue OpenURI::HTTPError, SocketError, Errno::ENOENT, Errno::EHOSTUNREACH, NoMethodError
  nil
end