Class: TTY::Reader::Console
- Inherits:
- 
      Object
      
        - Object
- TTY::Reader::Console
 
- Defined in:
- lib/tty/reader/console.rb
Constant Summary collapse
- ESC =
          
- "\e"
- CSI =
          
- "\e["
- TIMEOUT =
          
- 0.1
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
  
  
  
  
  
  
  
    A new instance of Console. 
Constructor Details
Instance Attribute Details
#escape_codes ⇒ Array[Integer] (readonly)
Escape codes
| 28 29 30 | # File 'lib/tty/reader/console.rb', line 28 def escape_codes @escape_codes end | 
#keys ⇒ Hash[Symbol] (readonly)
Key codes
| 21 22 23 | # File 'lib/tty/reader/console.rb', line 21 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
| 46 47 48 49 50 51 52 53 54 55 56 | # File 'lib/tty/reader/console.rb', line 46 def get_char() mode.raw([:raw]) do mode.echo([:echo]) do if [:nonblock] input.wait_readable(TIMEOUT) ? input.getc : nil else input.getc end end end end |