Class: IO

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

Instance Method Summary collapse

Instance Method Details

#readline_nonblock(sep = $INPUT_RECORD_SEPARATOR) ⇒ Object



2
3
4
5
6
7
8
9
# File 'Library/Homebrew/extend/io.rb', line 2

def readline_nonblock(sep = $INPUT_RECORD_SEPARATOR)
  buffer = ""
  buffer.concat(read_nonblock(1)) while buffer[-1] != sep
  buffer
rescue IO::WaitReadable, EOFError => e
  raise e if buffer.empty?
  buffer
end