module Nuggets::URI::ExistMixin
Public Class Methods
extended(base)
click to toggle source
# File lib/nuggets/uri/exist_mixin.rb 34 def self.extended(base) 35 base.extend Nuggets::URI::RedirectMixin 36 end
Public Instance Methods
exist?(uri) → +true+, +false+ or +nil+
click to toggle source
exist?(uri) { |res| ... } → anObject, +false+ or +nil+
Checks whether the URI
uri
exists by performing a HEAD
request. If successful, yields the response to the given block and returns its return value, or true
if no block was given. Returns false
in case of failure, or nil
if the redirect limit has been exceeded.
See Nuggets::URI::RedirectMixin#follow_redirect
for more information.
# File lib/nuggets/uri/exist_mixin.rb 48 def exist?(uri) 49 head_redirect(uri) { |res| res.success? && (!block_given? || yield(res)) } 50 end
Also aliased as: exists?