Class: HTTPAccess2::DebugSocket

Inherits:
TCPSocket
  • Object
show all
Defined in:
lib/http-access2.rb

Overview

HTTPAccess2::DebugSocket – debugging support

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ DebugSocket

Returns a new instance of DebugSocket.



1108
1109
1110
1111
# File 'lib/http-access2.rb', line 1108

def initialize(*args)
  super
  @debug_dev = nil
end

Instance Attribute Details

#debug_devObject

Device for logging.



1094
1095
1096
# File 'lib/http-access2.rb', line 1094

def debug_dev
  @debug_dev
end

Class Method Details

.create_socket(host, port, debug_dev) ⇒ Object



1097
1098
1099
1100
1101
1102
1103
# File 'lib/http-access2.rb', line 1097

def create_socket(host, port, debug_dev)
  debug_dev << "! CONNECT TO #{host}:#{port}\n"
  socket = new(host, port)
  socket.debug_dev = debug_dev
  socket.log_connect
  socket
end

Instance Method Details

#<<(str) ⇒ Object



1134
1135
1136
1137
# File 'lib/http-access2.rb', line 1134

def <<(str)
  super
  @debug_dev << str
end

#closeObject



1117
1118
1119
1120
# File 'lib/http-access2.rb', line 1117

def close
  super
  @debug_dev << '! CONNECTION CLOSED' << "\n"
end

#gets(*args) ⇒ Object



1122
1123
1124
1125
1126
# File 'lib/http-access2.rb', line 1122

def gets(*args)
  str = super
  @debug_dev << str if str
  str
end

#log_connectObject



1113
1114
1115
# File 'lib/http-access2.rb', line 1113

def log_connect
  @debug_dev << '! CONNECTION ESTABLISHED' << "\n"
end

#read(*args) ⇒ Object



1128
1129
1130
1131
1132
# File 'lib/http-access2.rb', line 1128

def read(*args)
  str = super
  @debug_dev << str if str
  str
end