class ClientForPoslynx::HasClientConsoleSupport::Connection

Attributes

config[RW]
io[RW]
tcp_connection[RW]

Public Class Methods

connect(config) click to toggle source
# File lib/client_for_poslynx/has_client_console_support/connection.rb, line 9
def self.connect(config)
  new(config).connect
end
new(config) click to toggle source
# File lib/client_for_poslynx/has_client_console_support/connection.rb, line 16
def initialize(config)
  self.config = config
end

Public Instance Methods

===(other) click to toggle source
# File lib/client_for_poslynx/has_client_console_support/connection.rb, line 40
def ===(other)
  self == other || self.io == other
end
close() click to toggle source
# File lib/client_for_poslynx/has_client_console_support/connection.rb, line 31
def close
  tcp_connection.close unless tcp_connection.closed?
  self.io = self.tcp_connection = nil
end
connect() click to toggle source
# File lib/client_for_poslynx/has_client_console_support/connection.rb, line 20
def connect
  self.tcp_connection = TCPSocket.new( config.host, config.port )
  self.io = config.use_ssl ?
    connect_ssl_socket :
    tcp_connection
  self
rescue StandardError
  close
  raise
end
puts(*args) click to toggle source
# File lib/client_for_poslynx/has_client_console_support/connection.rb, line 36
def puts(*args)
  io.puts *args
end

Private Instance Methods

connect_ssl_socket() click to toggle source
# File lib/client_for_poslynx/has_client_console_support/connection.rb, line 46
def connect_ssl_socket
  OpenSSL::SSL::SSLSocket.new( tcp_connection ).tap { |ssl_conn|
    ssl_conn.connect
  }
end