Class: RSMP::Protocol
- Inherits:
-
Object
- Object
- RSMP::Protocol
- Defined in:
- lib/rsmp/node/protocol.rb
Instance Method Summary collapse
-
#initialize(stream) ⇒ Protocol
constructor
A new instance of Protocol.
- #peek_line ⇒ Object
- #read_line ⇒ Object
- #write_lines(data) ⇒ Object
Constructor Details
#initialize(stream) ⇒ Protocol
Returns a new instance of Protocol.
3 4 5 6 |
# File 'lib/rsmp/node/protocol.rb', line 3 def initialize(stream) @stream = stream @peeked = nil end |
Instance Method Details
#peek_line ⇒ Object
18 19 20 21 |
# File 'lib/rsmp/node/protocol.rb', line 18 def peek_line @peeked ||= read @peeked end |
#read_line ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/rsmp/node/protocol.rb', line 8 def read_line if @peeked line = @peeked @peeked = nil line else read end end |
#write_lines(data) ⇒ Object
23 24 25 26 |
# File 'lib/rsmp/node/protocol.rb', line 23 def write_lines(data) @stream.write(data + RSMP::Proxy::WRAPPING_DELIMITER) @stream.flush unless @stream.closed? end |