Class: Finch::Pinger
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#last_success ⇒ Object
Returns the value of attribute last_success.
-
#name ⇒ Object
Returns the value of attribute name.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#state ⇒ Object
Returns the value of attribute state.
-
#timer ⇒ Object
readonly
Returns the value of attribute timer.
Instance Method Summary collapse
-
#initialize(name, opts = {}) ⇒ Pinger
constructor
A new instance of Pinger.
- #ping ⇒ Object
Constructor Details
#initialize(name, opts = {}) ⇒ Pinger
Returns a new instance of Pinger.
28 29 30 31 32 33 34 35 |
# File 'lib/finch.rb', line 28 def initialize(name, opts = {}) @name = name @host = opts.fetch(:host, "localhost") @group = opts.fetch(:group, "Default") @port = opts.fetch(:port, lambda { raise(ArgumentError) }) @timer = every(opts.fetch(:frequency, 30)) { ping } async.ping end |
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group.
25 26 27 |
# File 'lib/finch.rb', line 25 def group @group end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
25 26 27 |
# File 'lib/finch.rb', line 25 def host @host end |
#last_success ⇒ Object
Returns the value of attribute last_success.
26 27 28 |
# File 'lib/finch.rb', line 26 def last_success @last_success end |
#name ⇒ Object
Returns the value of attribute name.
26 27 28 |
# File 'lib/finch.rb', line 26 def name @name end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
25 26 27 |
# File 'lib/finch.rb', line 25 def port @port end |
#state ⇒ Object
Returns the value of attribute state.
26 27 28 |
# File 'lib/finch.rb', line 26 def state @state end |
#timer ⇒ Object (readonly)
Returns the value of attribute timer.
25 26 27 |
# File 'lib/finch.rb', line 25 def timer @timer end |
Instance Method Details
#ping ⇒ Object
37 38 39 |
# File 'lib/finch.rb', line 37 def ping ping_accessor.ping ? success : error end |