Module: URI
- Defined in:
- lib/nuggets/uri/exist.rb,
lib/nuggets/uri/content_type.rb
Class Method Summary collapse
-
.content_type(uri) ⇒ Object
call-seq: URI.content_type(uri) => aString or nil.
-
.exist?(uri) ⇒ Boolean
(also: exists?)
call-seq: URI.exist?(uri) => true or false.
Class 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.rb', line 39 def content_type(uri) open(uri.to_s).content_type rescue OpenURI::HTTPError, SocketError, Errno::ENOENT, Errno::EHOSTUNREACH, NoMethodError nil end |
.exist?(uri) ⇒ Boolean Also known as: exists?
call-seq:
URI.exist?(uri) => true or false
Return true if the named URI exists.
38 39 40 41 42 43 |
# File 'lib/nuggets/uri/exist.rb', line 38 def exist?(uri) open(uri.to_s) true rescue OpenURI::HTTPError, SocketError, Errno::ENOENT false end |