lib/tty/reader.rb
def read_multiline(prompt = "", value: "", echo: true, raw: true,
                       nonblock: false, exit_keys: EXIT_KEYS)
      lines = []
      stop = false
      clear_value = !value.to_s.empty?

      loop do
        line = read_line(prompt, value: value, echo: echo, raw: raw,
                                 nonblock: nonblock, exit_keys: exit_keys).to_s
        if clear_value
          clear_value = false
          value = ""
        end
        break if line.empty?

        stop = line.match(END_WITH_LINE_BREAK).nil?
        next if line !~ /\S/ && !stop

        if block_given?
          yield(line)
        else
          lines << line
        end
        break if stop
      end

      lines
    end
# Read multiple lines and return them in an array.
# Skip empty lines in the returned lines array.
# The input gathering is terminated by Ctrl+d or Ctrl+z.
#
# @param [String] prompt
#   the prompt displayed before the input
# @param [String] value
#   the value to pre-populate line with
# @param [Boolean] echo
#   whether to echo chars back or not, defaults to false
# @param [Array<Symbol>] exit_keys
#   the custom keys to exit line editing
# @option [Boolean] raw
#   whenther raw mode is enabled, defaults to true
# @option [Boolean] nonblock
#   whether to wait for input or not, defaults to false
#
# @yield [String] line
#
# @return [Array[String]]
#
# @api public
Read multiple lines and return them in an array.
Skip empty lines in the returned lines array.
The input gathering is terminated by Ctrl+d or Ctrl+z.
Read multiple lines and return them in an array . Skip empty lines in the returned lines array . The input gathering is terminated by Ctrl + d or Ctrl + z .
def read_multiline(prompt = "", value: "", echo: true, raw: true,
                       nonblock: false, exit_keys: EXIT_KEYS)
      lines = []
      stop = false
      clear_value = !value.to_s.empty?
      loop do
        line = read_line(prompt, value: value, echo: echo, raw: raw,
                                 nonblock: nonblock, exit_keys: exit_keys).to_s
        if clear_value
          clear_value = false
          value = ""
        end
        break if line.empty?
        stop = line.match(END_WITH_LINE_BREAK).nil?
        next if line !~ /\S/ && !stop
        if block_given?
          yield(line)
        else
          lines << line
        end
        break if stop
      end
      lines
    end
def read_multiline ( prompt = "" , value : "" , echo : true , raw : true , nonblock : false , exit_keys : EXIT_KEYS ) lines = [ ] stop = false clear_value = ! value . to_s . empty? loop do line = read_line ( prompt , value : value , echo : echo , raw : raw , nonblock : nonblock , exit_keys : exit_keys ) . to_s if clear_value clear_value = false value = "" end break if line . empty? stop = line . match ( END_WITH_LINE_BREAK ) . nil? next if line !~ / \S / && ! stop if block_given? yield ( line ) else lines << line end break if stop end lines end
Read multiple lines and return them in an array.
Read multiple lines and return them in an array .
None
Array[String
prompt
value
echo
raw
nonblock
exit_keys
nonblock whether to wait for input or not, defaults to false
nonblock whether to wait for input or not defaults to false
false
]
None
api
None