Class: BuildWatcher::FakeSerialPort
- Inherits:
-
Object
- Object
- BuildWatcher::FakeSerialPort
- Defined in:
- lib/build_watcher/fake_serial_port.rb
Instance Attribute Summary collapse
-
#messages_received ⇒ Object
readonly
Returns the value of attribute messages_received.
-
#messages_sent ⇒ Object
readonly
Returns the value of attribute messages_sent.
-
#projects ⇒ Object
readonly
Returns the value of attribute projects.
-
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize ⇒ FakeSerialPort
constructor
A new instance of FakeSerialPort.
-
#puts(content) ⇒ Object
If an array is passed in, the first element is “sent” and the second element is added to the list of messages recieved.
- #read ⇒ Object
- #register_project(public_key, private_key) ⇒ Object
Constructor Details
#initialize ⇒ FakeSerialPort
Returns a new instance of FakeSerialPort.
6 7 8 9 10 11 |
# File 'lib/build_watcher/fake_serial_port.rb', line 6 def initialize @projects = [] @messages_sent = [] @messages_received = [] @serial_buffer = [] end |
Instance Attribute Details
#messages_received ⇒ Object (readonly)
Returns the value of attribute messages_received.
3 4 5 |
# File 'lib/build_watcher/fake_serial_port.rb', line 3 def @messages_received end |
#messages_sent ⇒ Object (readonly)
Returns the value of attribute messages_sent.
3 4 5 |
# File 'lib/build_watcher/fake_serial_port.rb', line 3 def @messages_sent end |
#projects ⇒ Object (readonly)
Returns the value of attribute projects.
3 4 5 |
# File 'lib/build_watcher/fake_serial_port.rb', line 3 def projects @projects end |
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
4 5 6 |
# File 'lib/build_watcher/fake_serial_port.rb', line 4 def read_timeout @read_timeout end |
Instance Method Details
#close ⇒ Object
38 |
# File 'lib/build_watcher/fake_serial_port.rb', line 38 def close; end |
#puts(content) ⇒ Object
If an array is passed in, the first element is “sent” and the second element is added to the list of messages recieved
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/build_watcher/fake_serial_port.rb', line 20 def puts(content) , response = content @messages_sent << unless response.nil? @messages_received << response @serial_buffer << response end end |
#read ⇒ Object
32 33 34 35 36 |
# File 'lib/build_watcher/fake_serial_port.rb', line 32 def read buffers_contents = @serial_buffer.join @serial_buffer = [] buffers_contents end |
#register_project(public_key, private_key) ⇒ Object
13 14 15 |
# File 'lib/build_watcher/fake_serial_port.rb', line 13 def register_project(public_key, private_key) @projects << [public_key, private_key] end |