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.
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
#url ⇒ Object (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_s ⇒ Object 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 |
#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.
20 21 22 |
# File 'lib/mechanize/robots_disallowed_error.rb', line 20 def uri @uri ||= URI.parse(url) end |