Exception: Mechanize::RobotsDisallowedError
- 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
-
#url ⇒ Object
readonly
Returns the URL (string) of the resource that caused this error.
Instance Method Summary collapse
-
#initialize(url) ⇒ RobotsDisallowedError
constructor
A new instance of RobotsDisallowedError.
- #to_s ⇒ Object (also: #inspect)
-
#uri ⇒ Object
Returns the URL (URI object) of the resource that caused this error.
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
#url ⇒ Object (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_s ⇒ Object 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 |
#uri ⇒ Object
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 |