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
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/tty/terminal/echo.rb', line 26 def echo(is_on=true, &block) value = nil begin self.off unless is_on value = block.call if block_given? self.on return value rescue NoMethodError, Interrupt => e self.on exit end end |