Class: Pingify::Runnable
- Inherits:
-
Object
- Object
- Pingify::Runnable
- Defined in:
- lib/pingify.rb
Instance Attribute Summary collapse
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(options = { :timeout => 2.0, :open_timeout => 2.0 }) ⇒ Runnable
constructor
A new instance of Runnable.
- #run ⇒ Object
Constructor Details
#initialize(options = { :timeout => 2.0, :open_timeout => 2.0 }) ⇒ Runnable
Returns a new instance of Runnable.
10 11 12 13 14 |
# File 'lib/pingify.rb', line 10 def initialize(={ :timeout => 2.0, :open_timeout => 2.0 }) @uri = .delete :uri @times = .delete(:times) || 4 @http_opts = { :timeout => .delete(:timeout), :open_timeout => .delete(:open_timeout) } end |
Instance Attribute Details
#uri ⇒ Object
Returns the value of attribute uri.
8 9 10 |
# File 'lib/pingify.rb', line 8 def uri @uri end |
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/pingify.rb', line 16 def run res = ping! data = { :average => average_time(@times - 1), :body => res.body }.merge(ping_headers(res)) return Result.new(data) rescue return ErrorResult.new({}, [$!]) end |