class TTY::Prompt::Reader::Console

Constants

CSI
ESC

Attributes

escape_codes[R]

Escape codes

@return [Array]

@api public

input[R]
keys[R]

Key codes

@return [Hash]

@api public

mode[R]

Public Class Methods

new(input) click to toggle source
# File lib/tty/prompt/reader/console.rb, line 27
def initialize(input)
  @input = input
  @mode  = Mode.new(input)
  @keys  = Codes.keys
  @escape_codes = [[ESC.ord], CSI.bytes.to_a]
end

Public Instance Methods

get_char(options) click to toggle source

Get a character from console with echo

@param [Hash] options @option options [Symbol] :echo

the echo toggle

@return [String]

@api private

# File lib/tty/prompt/reader/console.rb, line 43
def get_char(options)
  mode.raw(options[:raw]) do
    mode.echo(options[:echo]) { input.getc }
  end
end