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
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) ⇒ Object
- #read(bytes) ⇒ Object
- #read_nonblock(*args) ⇒ Object
- #setsockopt(*args) ⇒ Object
- #to_io ⇒ Object
- #write(str) ⇒ Object
Constructor Details
#initialize(address, port, cassette) ⇒ RecordableTCPSocket
Returns a new instance of RecordableTCPSocket.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 11 def initialize(address, port, cassette) raise TCR::NoCassetteError.new unless TCR.cassette @read_lock = Queue.new if cassette.recording? @live = true @socket = TCPSocket.real_open(address, port) else @live = false @closed = false end @recording = cassette.next_session 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
Returns the value of attribute recording.
9 10 11 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 9 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
65 66 67 68 69 70 71 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 65 def close if live @socket.close else @closed = true end end |
#closed? ⇒ Boolean
57 58 59 60 61 62 63 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 57 def closed? if live @socket.closed? else @closed end end |
#getc(*args) ⇒ Object
30 31 32 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 30 def getc(*args) _read(:getc, *args) end |
#gets(*args) ⇒ Object
34 35 36 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 34 def gets(*args) _read(:gets, *args) end |
#print(str) ⇒ Object
42 43 44 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 42 def print(str) _write(:print, str) end |
#read(bytes) ⇒ Object
26 27 28 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 26 def read(bytes) _read(:read, bytes) end |
#read_nonblock(*args) ⇒ Object
38 39 40 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 38 def read_nonblock(*args) _read(:read_nonblock, *args, blocking: false) end |
#setsockopt(*args) ⇒ Object
73 74 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 73 def setsockopt(*args) end |
#to_io ⇒ Object
51 52 53 54 55 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 51 def to_io if live @socket.to_io end end |
#write(str) ⇒ Object
46 47 48 49 |
# File 'lib/tcr/recordable_tcp_socket.rb', line 46 def write(str) _write(:write, str) str.length end |