Class: Sanford::Protocol::FakeConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/sanford-protocol/fake_connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#closedObject

Returns the value of attribute closed.



7
8
9
# File 'lib/sanford-protocol/fake_connection.rb', line 7

def closed
  @closed
end

#closed_writeObject

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_dataObject

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_timeoutObject (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_dataObject

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_timeoutObject (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_dataObject

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

#closeObject



36
37
38
# File 'lib/sanford-protocol/fake_connection.rb', line 36

def close
  @closed = true
end

#close_writeObject



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