Class: OtStatus::Query

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

Defined Under Namespace

Classes: Connection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connect_timeout = 5, inactivity_timeout = 10) ⇒ Query

Returns a new instance of Query.



11
12
13
14
15
# File 'lib/otstatus.rb', line 11

def initialize connect_timeout=5, inactivity_timeout=10
  @response = nil
  @connect_timeout = connect_timeout
  @inactivity_timeout = inactivity_timeout
end

Instance Attribute Details

#responseObject

Returns the value of attribute response.



9
10
11
# File 'lib/otstatus.rb', line 9

def response
  @response
end

Instance Method Details

#run(hostname, port) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/otstatus.rb', line 17

def run hostname, port
  EventMachine.run {
    EventMachine::connect hostname, port, Connection, self, @connect_timeout, @inactivity_timeout
  }

  parse @response
end