Class: AcpcPokerBasicProxy::DealerStream
- Inherits:
-
TCPSocket
- Object
- TCPSocket
- AcpcPokerBasicProxy::DealerStream
- Defined in:
- lib/acpc_poker_basic_proxy/dealer_stream.rb
Constant Summary collapse
- VERSION_LABEL =
Returns The ACPC dealer version label.
'VERSION'
- VERSION_NUMBERS =
Returns The ACPC dealer version numbers.
{:major => 2, :minor => 0, :revision => 0}
- TERMINATION_STRING =
Returns Dealer specified string terminator.
"\r\n"
- READY_MESSAGE =
'#READY'
Instance Method Summary collapse
-
#gets ⇒ String
Retrieves a string from the dealer.
-
#initialize(port, host_name = 'localhost') ⇒ DealerStream
constructor
A new instance of DealerStream.
- #ready_to_read? ⇒ Boolean
- #ready_to_write? ⇒ Boolean
-
#write(string) ⇒ Integer
Sends a given
string
to the dealer.
Constructor Details
#initialize(port, host_name = 'localhost') ⇒ DealerStream
Returns a new instance of DealerStream.
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/acpc_poker_basic_proxy/dealer_stream.rb', line 65 def initialize(port, host_name='localhost') @dealer_socket = nil begin @dealer_socket = TCPSocket.new(host_name, port) super @dealer_socket send_version_string_to_dealer rescue UnableToWriteToDealer raise rescue Errno::ECONNREFUSED => e handle_error UnableToConnectToDealer, "Unable to connect to the dealer on #{host_name} through port #{port}", e end end |
Instance Method Details
#gets ⇒ String
Retrieves a string from the dealer.
83 84 85 86 87 88 89 |
# File 'lib/acpc_poker_basic_proxy/dealer_stream.rb', line 83 def gets begin string_from_dealer rescue => e handle_error UnableToGetFromDealer, "Unable to get a string from the dealer", e end end |
#ready_to_read? ⇒ Boolean
110 111 112 |
# File 'lib/acpc_poker_basic_proxy/dealer_stream.rb', line 110 def ready_to_read? @dealer_socket.ready_to_read? end |
#ready_to_write? ⇒ Boolean
105 106 107 |
# File 'lib/acpc_poker_basic_proxy/dealer_stream.rb', line 105 def ready_to_write? @dealer_socket.ready_to_write? end |
#write(string) ⇒ Integer
Sends a given string
to the dealer.
96 97 98 99 100 101 102 |
# File 'lib/acpc_poker_basic_proxy/dealer_stream.rb', line 96 def write(string) begin send_string_to_dealer string rescue => e handle_error UnableToWriteToDealer, "Unable to send the string, \"#{string}\", to the dealer", e end end |