Class: Pandemic::ClientSide::Connection
- Inherits:
-
Object
- Object
- Pandemic::ClientSide::Connection
- Defined in:
- lib/pandemic/client_side/connection.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #died! ⇒ Object
- #ensure_alive! ⇒ Object
-
#initialize(host, port, key) ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize(host, port, key) ⇒ Connection
Returns a new instance of Connection.
5 6 7 8 |
# File 'lib/pandemic/client_side/connection.rb', line 5 def initialize(host, port, key) @host, @port, @key = host, port, key connect end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
4 5 6 |
# File 'lib/pandemic/client_side/connection.rb', line 4 def key @key end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
4 5 6 |
# File 'lib/pandemic/client_side/connection.rb', line 4 def socket @socket end |
Instance Method Details
#alive? ⇒ Boolean
10 11 12 |
# File 'lib/pandemic/client_side/connection.rb', line 10 def alive? @socket && !@socket.closed? end |
#died! ⇒ Object
18 19 20 21 |
# File 'lib/pandemic/client_side/connection.rb', line 18 def died! @socket.close if self.alive? @socket = nil end |
#ensure_alive! ⇒ Object
14 15 16 |
# File 'lib/pandemic/client_side/connection.rb', line 14 def ensure_alive! connect unless self.alive? end |