Module: Nuggets::URI::ExistMixin
- Included in:
- URI
- Defined in:
- lib/nuggets/uri/exist_mixin.rb
Class Method Summary (collapse)
Instance Method Summary (collapse)
-
- (Boolean) exist?(uri)
(also: #exists?)
call-seq:.
Class Method Details
+ (Object) extended(base)
35 36 37 |
# File 'lib/nuggets/uri/exist_mixin.rb', line 35 def self.extended(base) base.extend Nuggets::URI::RedirectMixin end |
Instance Method Details
- (Boolean) exist?(uri) Also known as: exists?
call-seq:
URI.exist?(uri) => +true+, +false+ or +nil+
URI.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.
49 50 51 |
# File 'lib/nuggets/uri/exist_mixin.rb', line 49 def exist?(uri) head_redirect(uri) { |res| res.success? && (!block_given? || yield(res)) } end |