Class: Sanford::Protocol::FakeConnection
- Inherits:
-
Object
- Object
- Sanford::Protocol::FakeConnection
- Defined in:
- lib/sanford-protocol/fake_connection.rb
Instance Attribute Summary collapse
-
#closed ⇒ Object
Returns the value of attribute closed.
-
#closed_write ⇒ Object
Returns the value of attribute closed_write.
-
#peek_data ⇒ Object
Returns the value of attribute peek_data.
-
#peek_timeout ⇒ Object
readonly
Returns the value of attribute peek_timeout.
-
#read_data ⇒ Object
Returns the value of attribute read_data.
-
#read_timeout ⇒ Object
readonly
Returns the value of attribute read_timeout.
-
#write_data ⇒ Object
Returns the value of attribute write_data.
Instance Method Summary collapse
- #close ⇒ Object
- #close_write ⇒ Object
-
#initialize(read_data = nil) ⇒ FakeConnection
constructor
A new instance of FakeConnection.
- #peek(timeout = nil) ⇒ Object
- #read(timeout = nil) ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize(read_data = nil) ⇒ FakeConnection
Returns a new instance of FakeConnection.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sanford-protocol/fake_connection.rb', line 10 def initialize(read_data = nil) @read_data = read_data || "" @peek_data = read_data ? read_data[1] : "" @write_data = nil @read_timeout = nil @peek_timeout = nil @closed = false @closed_write = false end |
Instance Attribute Details
#closed ⇒ Object
Returns the value of attribute closed.
7 8 9 |
# File 'lib/sanford-protocol/fake_connection.rb', line 7 def closed @closed end |
#closed_write ⇒ Object
Returns the value of attribute closed_write.
7 8 9 |
# File 'lib/sanford-protocol/fake_connection.rb', line 7 def closed_write @closed_write end |
#peek_data ⇒ Object
Returns the value of attribute peek_data.
6 7 8 |
# File 'lib/sanford-protocol/fake_connection.rb', line 6 def peek_data @peek_data end |
#peek_timeout ⇒ Object (readonly)
Returns the value of attribute peek_timeout.
8 9 10 |
# File 'lib/sanford-protocol/fake_connection.rb', line 8 def peek_timeout @peek_timeout end |
#read_data ⇒ Object
Returns the value of attribute read_data.
6 7 8 |
# File 'lib/sanford-protocol/fake_connection.rb', line 6 def read_data @read_data end |
#read_timeout ⇒ Object (readonly)
Returns the value of attribute read_timeout.
8 9 10 |
# File 'lib/sanford-protocol/fake_connection.rb', line 8 def read_timeout @read_timeout end |
#write_data ⇒ Object
Returns the value of attribute write_data.
6 7 8 |
# File 'lib/sanford-protocol/fake_connection.rb', line 6 def write_data @write_data end |
Instance Method Details
#close ⇒ Object
36 37 38 |
# File 'lib/sanford-protocol/fake_connection.rb', line 36 def close @closed = true end |
#close_write ⇒ Object
40 41 42 |
# File 'lib/sanford-protocol/fake_connection.rb', line 40 def close_write @closed_write = true end |
#peek(timeout = nil) ⇒ Object
31 32 33 34 |
# File 'lib/sanford-protocol/fake_connection.rb', line 31 def peek(timeout = nil) @peek_timeout = timeout @peek_data end |
#read(timeout = nil) ⇒ Object
22 23 24 25 |
# File 'lib/sanford-protocol/fake_connection.rb', line 22 def read(timeout = nil) @read_timeout = timeout @read_data end |
#write(data) ⇒ Object
27 28 29 |
# File 'lib/sanford-protocol/fake_connection.rb', line 27 def write(data) @write_data = data end |