Spec-Zone.ru › Homebrew

Class: ReadlineNonblock Private

Inherits:
Object
  • Object
  • ReadlineNonblock
show all
Defined in:
readline_nonblock.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.

Class Method Summary collapse

  • .read(io) ⇒ String private

Class Method Details

.read(io) ⇒ String

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.

Parameters:

  • io (IO)

Returns:

  • (String)


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

def self.read(io)
  line = +""
  buffer = +""

  begin
    loop do
      break if buffer == $INPUT_RECORD_SEPARATOR

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

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

    line.freeze
  end
end

© 2009–present Homebrew contributors
Licensed under the BSD 2-Clause License.
https://docs.brew.sh/rubydoc/ReadlineNonblock.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API