Class: LIS::Transfer::LineBasedProtocol
- Inherits:
-
Base
- Object
- Base
- LIS::Transfer::LineBasedProtocol
- Defined in:
- lib/lis/io_listener.rb
Instance Method Summary (collapse)
-
- (Object) receive(data)
strip newlines from received data and pass on complete lines.
-
- (Object) write(data)
add a newline to data and pass it on.
Methods inherited from Base
#<<, #forward, #initialize, #on_data
Constructor Details
This class inherits a constructor from LIS::Transfer::Base
Instance Method Details
- (Object) receive(data)
strip newlines from received data and pass on complete lines
88 89 90 91 92 93 94 95 96 |
# File 'lib/lis/io_listener.rb', line 88 def receive(data) @memo ||= "" scanner = StringScanner.new(@memo + data) while s = scanner.scan(/.*?\n/) forward(s.strip) end @memo = scanner.rest nil end |
- (Object) write(data)
add a newline to data and pass it on
101 102 103 |
# File 'lib/lis/io_listener.rb', line 101 def write(data) super(data + "\n") end |