Class: LinkChecker::Typhoeus::Hydra::Result
- Inherits:
-
Result
- Object
- Result
- LinkChecker::Typhoeus::Hydra::Result
show all
- Defined in:
- lib/ruby-link-checker/typhoeus/hydra/result.rb
Instance Attribute Summary collapse
Attributes inherited from Result
#checker, #method, #options, #result_uri, #uri
Instance Method Summary
collapse
Methods inherited from Result
#error, #to_s
Constructor Details
#initialize(uri, method, original_uri, request, response, options) ⇒ Result
Returns a new instance of Result.
7
8
9
10
11
|
# File 'lib/ruby-link-checker/typhoeus/hydra/result.rb', line 7
def initialize(uri, method, original_uri, request, response, options)
@request = request
@response = response
super uri, method, original_uri, options
end
|
Instance Attribute Details
#request ⇒ Object
Returns the value of attribute request.
5
6
7
|
# File 'lib/ruby-link-checker/typhoeus/hydra/result.rb', line 5
def request
@request
end
|
#response ⇒ Object
Returns the value of attribute response.
5
6
7
|
# File 'lib/ruby-link-checker/typhoeus/hydra/result.rb', line 5
def response
@response
end
|
Instance Method Details
#code ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/ruby-link-checker/typhoeus/hydra/result.rb', line 21
def code
@code ||= begin
response.code.to_i
rescue StandardError
-1
end
end
|
#error? ⇒ Boolean
13
14
15
|
# File 'lib/ruby-link-checker/typhoeus/hydra/result.rb', line 13
def error?
false
end
|
#failure? ⇒ Boolean
17
18
19
|
# File 'lib/ruby-link-checker/typhoeus/hydra/result.rb', line 17
def failure?
!success? && !redirect? && !error?
end
|
#redirect? ⇒ Boolean
39
40
41
42
43
|
# File 'lib/ruby-link-checker/typhoeus/hydra/result.rb', line 39
def redirect?
return false unless response
[301, 302, 303, 307, 308].include?(code)
end
|
#redirect_to ⇒ Object
33
34
35
36
37
|
# File 'lib/ruby-link-checker/typhoeus/hydra/result.rb', line 33
def redirect_to
return nil unless response
response.['Location']
end
|
29
30
31
|
# File 'lib/ruby-link-checker/typhoeus/hydra/result.rb', line 29
def
request.options[:headers]
end
|
#success? ⇒ Boolean
45
46
47
48
49
|
# File 'lib/ruby-link-checker/typhoeus/hydra/result.rb', line 45
def success?
return false unless response
code >= 200 && code <= 299
end
|