Class: IO

Inherits:
Object
  • Object
show all
Defined in:
lib/prcs/core_ext.rb

Instance Method Summary collapse

Instance Method Details

#readline_nonblockObject



3
4
5
6
7
8
9
10
11
12
# File 'lib/prcs/core_ext.rb', line 3

def readline_nonblock
  buffer = ""
  buffer << read_nonblock(1) while buffer[-1] != "\n"

  buffer
rescue IO::WaitReadable => blocking
  raise blocking if buffer.empty?

  buffer
end