Class: RankMirror::Reachable

Inherits:
Object
  • Object
show all
Defined in:
lib/rankmirror/reachable.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri, timeout) ⇒ Reachable

Returns a new instance of Reachable.



5
6
7
8
# File 'lib/rankmirror/reachable.rb', line 5

def initialize(uri,timeout)
	@uri = uri
	@timeout = timeout
end

Instance Method Details

#reachable?Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rankmirror/reachable.rb', line 10

def reachable?
	begin
		r = Curl::Easy.new(@uri)
		r.timeout_ms = @timeout
		r.perform
		if r.response_code == 404
			false
		else
			true
		end
	rescue
		return false
	end
end