Class: Sappho::Socket::MockSocketRead

Inherits:
Object
  • Object
show all
Defined in:
lib/sappho-socket/mock_socket.rb

Instance Method Summary collapse

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

Raises:

  • (Timeout::Error)


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