module Nuggets::URI::ExistMixin

Public Class Methods

extended(base) click to toggle source
# File lib/nuggets/uri/exist_mixin.rb, line 34
def self.extended(base)
  base.extend Nuggets::URI::RedirectMixin

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, line 48
def exist?(uri)
  head_redirect(uri) { |res| res.success? && (!block_given? || yield(res)) }
Also aliased as: exists?
Alias for: exist?