Class: QandAClient
- Inherits:
-
Object
- Object
- QandAClient
- Defined in:
- lib/q_and_a_client.rb
Instance Method Summary collapse
- #connect ⇒ Object
- #connected? ⇒ Boolean
-
#initialize(q_and_a_window, host = "localhost", port = 3000) ⇒ QandAClient
constructor
A new instance of QandAClient.
Constructor Details
#initialize(q_and_a_window, host = "localhost", port = 3000) ⇒ QandAClient
Returns a new instance of QandAClient.
4 5 6 7 8 9 10 11 |
# File 'lib/q_and_a_client.rb', line 4 def initialize q_and_a_window, host="localhost", port=3000 @q_and_a_window = q_and_a_window @host = host || "localhost" @port = port.zero? ? 3000 : port @socket = connect @q_and_a_window.scrollok true listen if connected? end |
Instance Method Details
#connect ⇒ Object
13 14 15 16 17 |
# File 'lib/q_and_a_client.rb', line 13 def connect TCPSocket.new @host, @port rescue nil end |
#connected? ⇒ Boolean
19 20 21 |
# File 'lib/q_and_a_client.rb', line 19 def connected? !@socket.nil? end |