Class: IO Private

Inherits:
Object show all
Defined in:
extend/io.rb

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Instance Method Summary collapse

Instance Method Details

#readline_nonblock(sep = $INPUT_RECORD_SEPARATOR) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'extend/io.rb', line 5

def readline_nonblock(sep = $INPUT_RECORD_SEPARATOR)
  line = +""
  buffer = +""

  begin
    loop do
      break if buffer == sep

      read_nonblock(1, buffer)
      line.concat(buffer)
    end

    line.freeze
  rescue IO::WaitReadable, EOFError
    raise if line.empty?

    line.freeze
  end
end