class IO

ref: github.com/Homebrew/brew/blob/6b2dbbc96f7d8aa12f9b8c9c60107c9cc58befc4/Library/Homebrew/extend/io.rb

Public Instance Methods

readline_nonblock(sep = $INPUT_RECORD_SEPARATOR) click to toggle source
# File lib/fusuma/plugin/inputs/input.rb, line 67
def readline_nonblock(sep = $INPUT_RECORD_SEPARATOR)
  line = +''
  buffer = +''

  loop do
    break if buffer == sep

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

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

  line.freeze
end