Class: Sappho::Socket::MockSocketRead
- Inherits:
-
Object
- Object
- Sappho::Socket::MockSocketRead
- Defined in:
- lib/sappho-socket/mock_socket.rb
Instance Method Summary collapse
- #action(bytesNeeded) ⇒ Object
-
#initialize(str) ⇒ MockSocketRead
constructor
A new instance of MockSocketRead.
Constructor Details
#initialize(str) ⇒ MockSocketRead
Returns a new instance of MockSocketRead.
86 87 88 |
# File 'lib/sappho-socket/mock_socket.rb', line 86 def initialize str @str = str end |
Instance Method Details
#action(bytesNeeded) ⇒ Object
90 91 92 93 94 95 96 97 |
# File 'lib/sappho-socket/mock_socket.rb', line 90 def action bytesNeeded unless bytesNeeded >= @str.length raise MockSocketSessionError, "Expected read of #{@str.length} bytes but got request for #{bytesNeeded}" end raise Timeout::Error if bytesNeeded > @str.length @str end |