Class: UriFormatValidator::Reacher
- Inherits:
-
Object
- Object
- UriFormatValidator::Reacher
- Defined in:
- lib/uri_format_validator/reacher.rb
Overview
Reacher is a minimalist net client which purpose is to determine whether given URL is resolvable, host is reachable, and content is retrievable.
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url) ⇒ Reacher
constructor
A new instance of Reacher.
-
#retrievable? ⇒ Boolean
Tests whether given
urlis retrievable, that is making a HEAD request results with 2xx status code.
Constructor Details
#initialize(url) ⇒ Reacher
12 13 14 |
# File 'lib/uri_format_validator/reacher.rb', line 12 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
10 11 12 |
# File 'lib/uri_format_validator/reacher.rb', line 10 def url @url end |
Instance Method Details
#retrievable? ⇒ Boolean
Tests whether given url is retrievable, that is making a HEAD request results with 2xx status code.
18 19 20 |
# File 'lib/uri_format_validator/reacher.rb', line 18 def retrievable? head_response.is_a?(Net::HTTPSuccess) end |