Class: TTY::Prompt::Reader::Console Private
- Inherits:
-
Object
- Object
- TTY::Prompt::Reader::Console
- Defined in:
- lib/tty/prompt/reader/console.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- ESC =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"\e".freeze
- CSI =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"\e[".freeze
Instance Attribute Summary collapse
-
#escape_codes ⇒ Array[Integer]
readonly
Escape codes.
-
#keys ⇒ Hash[Symbol]
readonly
Key codes.
Instance Method Summary collapse
-
#get_char(options) ⇒ String
private
Get a character from console with echo.
-
#initialize(input) ⇒ Console
constructor
private
A new instance of Console.
Constructor Details
#initialize(input) ⇒ Console
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Console.
27 28 29 30 31 32 |
# 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 |
Instance Attribute Details
#escape_codes ⇒ Array[Integer] (readonly)
Escape codes
25 26 27 |
# File 'lib/tty/prompt/reader/console.rb', line 25 def escape_codes @escape_codes end |
#keys ⇒ Hash[Symbol] (readonly)
Key codes
18 19 20 |
# File 'lib/tty/prompt/reader/console.rb', line 18 def keys @keys end |
Instance Method Details
#get_char(options) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get a character from console with echo
43 44 45 46 47 |
# File 'lib/tty/prompt/reader/console.rb', line 43 def get_char() mode.raw([:raw]) do mode.echo([:echo]) { input.getc } end end |