Class: LIS::Transfer::LineBasedProtocol

Inherits:
Base
  • Object
show all
Defined in:
lib/lis/io_listener.rb

Instance Method Summary (collapse)

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

Parameters:

  • data (String)


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

Parameters:

  • data (String)


101
102
103
# File 'lib/lis/io_listener.rb', line 101

def write(data)
  super(data + "\n")
end