Class: Messed::Util::RemoteStatus
- Inherits:
-
Object
- Object
- Messed::Util::RemoteStatus
- Defined in:
- lib/messed/util/remote_status.rb
Defined Under Namespace
Classes: StatusHandler
Instance Attribute Summary collapse
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(host, port) ⇒ RemoteStatus
constructor
A new instance of RemoteStatus.
Constructor Details
#initialize(host, port) ⇒ RemoteStatus
Returns a new instance of RemoteStatus.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/messed/util/remote_status.rb', line 24 def initialize(host, port) host ||= '127.0.0.1' @status = {} EM.run do EM.add_timer(5) { @status['error'] = "timeout on connect" EM.stop_event_loop } begin EM.connect(host, port, StatusHandler) do |handler| handler.status = @status end rescue @status['error'] = "can't connect" EM.stop_event_loop end end end |
Instance Attribute Details
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/messed/util/remote_status.rb', line 5 def status @status end |