Class: TTY::Terminal::Echo
- Inherits:
-
Object
- Object
- TTY::Terminal::Echo
- Defined in:
- lib/tty/terminal/echo.rb
Overview
A class responsible for toggling echo.
Instance Method Summary collapse
-
#echo(is_on = true, &block) ⇒ Object
Wrap code block inside echo.
-
#off ⇒ Object
Turn echo off.
-
#on ⇒ Object
Turn echo on.
Instance Method Details
#echo(is_on = true, &block) ⇒ Object
Wrap code block inside echo
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tty/terminal/echo.rb', line 24 def echo(is_on=true, &block) value = nil begin off unless is_on value = block.call if block_given? on return value rescue NoMethodError, Interrupt on exit end end |
#off ⇒ Object
Turn echo off
17 18 19 |
# File 'lib/tty/terminal/echo.rb', line 17 def off %x{stty -echo} if TTY::Platform.unix? end |
#on ⇒ Object
Turn echo on
10 11 12 |
# File 'lib/tty/terminal/echo.rb', line 10 def on %x{stty echo} if TTY::Platform.unix? end |