Sha256: f8b37df11396e722d450dbb5dfcfe804fef157592f77e27a56ebb7ddf1dca704

Contents?: true

Size: 774 Bytes

Versions: 5

Compression:

Stored size: 774 Bytes

Contents

class Mechanize
  # Exception that is raised when an access to a resource is
  # disallowed by robots.txt or by HTML document itself.
  class RobotsDisallowedError < Mechanize::Error
    def initialize(url)
      if url.is_a?(URI)
        @url = url.to_s
        @uri = url
      else
        @url = url.to_s
      end
    end

    # Returns the URL (string) of the resource that caused this error.
    attr_reader :url

    # Returns the URL (URI object) of the resource that caused this
    # error.  URI::InvalidURIError may be raised if the URL happens to
    # be invalid or not understood by the URI library.
    def uri
      @uri ||= URI.parse(url)
    end

    def to_s
      "Robots access is disallowed for URL: #{url}"
    end
    alias :inspect :to_s
  end
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
aai10-mechanize-2.0.1.0 lib/mechanize/robots_disallowed_error.rb
neocoin-mechanize-2.0.2 lib/mechanize/robots_disallowed_error.rb
mechanize-2.0.1 lib/mechanize/robots_disallowed_error.rb
mechanize-2.0 lib/mechanize/robots_disallowed_error.rb
mechanize-2.0.pre.2 lib/mechanize/robots_disallowed_error.rb