Class: TCR::RecordableTCPSocket
- Inherits:
-
Object
- Object
- TCR::RecordableTCPSocket
- Includes:
- Net::BER::BERParser, Net::LDAP::Connection::GetbyteForSSLSocket
- Defined in:
- lib/tcr/recordable_tcp_socket.rb,
lib/tcr/net/ldap.rb
Instance Attribute Summary collapse
-
#live ⇒ Object
readonly
Returns the value of attribute live.
-
#recording ⇒ Object
readonly
Returns the value of attribute recording.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
- #getc(*args) ⇒ Object
- #gets(*args) ⇒ Object
-
#initialize(address, port, cassette) ⇒ RecordableTCPSocket
constructor
A new instance of RecordableTCPSocket.
- #print(str, *args) ⇒ Object
- #read(*args) ⇒ Object
- #read_nonblock(*args) ⇒ Object
- #setsockopt(*args) ⇒ Object
- #to_io ⇒ Object
- #write(str, *args) ⇒ Object
- #write_nonblock(str, *args) ⇒ Object
Constructor Details
#initialize(address, port, cassette) ⇒ RecordableTCPSocket
Returns a new instance of RecordableTCPSocket.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 10 def initialize(address, port, cassette) raise TCR::NoCassetteError.new unless TCR.cassette @read_lock = Queue.new @recording = cassette.next_session @live = cassette.recording? if live begin @socket = TCPSocket.real_open(address, port) rescue => e recording << ["error", Marshal.dump(e)] raise end else @closed = false check_recording_for_errors end end |
Instance Attribute Details
#live ⇒ Object (readonly)
Returns the value of attribute live.
8 9 10 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 8 def live @live end |
#recording ⇒ Object (readonly)
Returns the value of attribute recording.
8 9 10 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 8 def recording @recording end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
8 9 10 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 8 def socket @socket end |
Instance Method Details
#close ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 74 def close if live @socket.close else @closed = true end end |
#closed? ⇒ Boolean
66 67 68 69 70 71 72 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 66 def closed? if live @socket.closed? else @closed end end |
#getc(*args) ⇒ Object
34 35 36 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 34 def getc(*args) _read(:getc, args) end |
#gets(*args) ⇒ Object
38 39 40 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 38 def gets(*args) _read(:gets, args) end |
#print(str, *args) ⇒ Object
46 47 48 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 46 def print(str, *args) _write(:print, str, args) end |
#read(*args) ⇒ Object
30 31 32 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 30 def read(*args) _read(:read, args) end |
#read_nonblock(*args) ⇒ Object
42 43 44 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 42 def read_nonblock(*args) _read(:read_nonblock, args, blocking: false) end |
#setsockopt(*args) ⇒ Object
82 83 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 82 def setsockopt(*args) end |
#to_io ⇒ Object
60 61 62 63 64 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 60 def to_io if live @socket.to_io end end |
#write(str, *args) ⇒ Object
50 51 52 53 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 50 def write(str, *args) _write(:write, str, args) str.length end |
#write_nonblock(str, *args) ⇒ Object
55 56 57 58 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 55 def write_nonblock(str, *args) _write(:write_nonblock, str, args) str.length end |