Exception: Mechanize::RobotsDisallowedError

Inherits:
Error
  • Object
show all
Defined in:
lib/mechanize/robots_disallowed_error.rb

Overview

Exception that is raised when an access to a resource is disallowed by robots.txt or by HTML document itself.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ RobotsDisallowedError

Returns a new instance of RobotsDisallowedError.



5
6
7
8
9
10
11
12
# File 'lib/mechanize/robots_disallowed_error.rb', line 5

def initialize(url)
  if url.is_a?(URI)
    @url = url.to_s
    @uri = url
  else
    @url = url.to_s
  end
end

Instance Attribute Details

#urlObject (readonly)

Returns the URL (string) of the resource that caused this error.



15
16
17
# File 'lib/mechanize/robots_disallowed_error.rb', line 15

def url
  @url
end

Instance Method Details

#to_sObject Also known as: inspect



24
25
26
# File 'lib/mechanize/robots_disallowed_error.rb', line 24

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

#uriObject

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.



20
21
22
# File 'lib/mechanize/robots_disallowed_error.rb', line 20

def uri
  @uri ||= URI.parse(url)
end