Class: IO

Inherits:
Object
  • Object
show all
Defined in:
lib/fusuma/plugin/inputs/input.rb

Overview

Instance Method Summary collapse

Instance Method Details

#readline_nonblock(sep = $INPUT_RECORD_SEPARATOR) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# 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