Class: UriFormatValidator::Reacher

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#urlObject (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