Class: FSR::FakeSocket

Inherits:
Object
  • Object
show all
Defined in:
lib/fsr/fake_socket.rb

Instance Method Summary collapse

Constructor Details

#initialize(remote_host, remote_port) ⇒ FakeSocket

Returns a new instance of FakeSocket.



7
8
9
10
11
12
# File 'lib/fsr/fake_socket.rb', line 7

def initialize(remote_host, remote_port)
  @remote_host, @remote_port = remote_host, remote_port

  @input = StringIO.new('')
  @buffer = []
end

Instance Method Details

#addressObject



18
19
20
# File 'lib/fsr/fake_socket.rb', line 18

def address
  '127.0.0.1'
end

#closeObject



27
28
# File 'lib/fsr/fake_socket.rb', line 27

def close
end

#eof?Boolean Also known as: closed?

Returns:

  • (Boolean)


22
23
24
# File 'lib/fsr/fake_socket.rb', line 22

def eof?
  @input.eof?
end

#fake_bufferObject



42
43
44
# File 'lib/fsr/fake_socket.rb', line 42

def fake_buffer
  @buffer
end

#fake_inputObject



38
39
40
# File 'lib/fsr/fake_socket.rb', line 38

def fake_input
  @input
end

#hostnameObject



14
15
16
# File 'lib/fsr/fake_socket.rb', line 14

def hostname
  'localhost'
end


30
31
32
# File 'lib/fsr/fake_socket.rb', line 30

def print(*args)
  @buffer << args.join
end

#read(len) ⇒ Object



34
35
36
# File 'lib/fsr/fake_socket.rb', line 34

def read(len)
  @input.read(len)
end