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.



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

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.



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

def url
  @url
end

Instance Method Details

#to_sObject Also known as: inspect



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

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.



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

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