Method: LCR::LineReader#initialize

Defined in:
lib/long-command-runner/line_reader.rb

#initialize(streams) {|io0_new_line, io1_new_line, ...| ... } ⇒ LineReader

Initializer takes an array of IO streams. You can optionaly pass a block that will be called at each new line.

The block will be called with as must as IO stream there is to treat.

Yields:

  • (io0_new_line, io1_new_line, ...)

    Will be called each time a new line is read.

Yield Parameters:

  • io0_new_line (String | nil)

    The string read as a new line without the endline characters. It will be nil if the new line detected is not on the first IO given in the initializer.

  • io1io1_new_line (String | nil)

    Same as previous param except it is for IO stream at index 1 given to the initializer.

Yield Returns:

  • (void)

    It is ignored.



25
26
27
28
29
# File 'lib/long-command-runner/line_reader.rb', line 25

def initialize(streams, &on_input)
  @streams = streams
  @streams_lines = Array.new(streams.length) { [] }
  @on_input = on_input
end