Class: TTY2::Reader::Mode
- Inherits:
-
Object
- Object
- TTY2::Reader::Mode
- Defined in:
- lib/tty2/reader/mode.rb
Instance Method Summary collapse
-
#echo(is_on = true, &block) ⇒ Object
Echo given block.
-
#initialize(input = $stdin) ⇒ Mode
constructor
Initialize a Terminal.
-
#raw(is_on = true, &block) ⇒ Object
Use raw mode in the given block.
Constructor Details
#initialize(input = $stdin) ⇒ Mode
Initialize a Terminal
11 12 13 |
# File 'lib/tty2/reader/mode.rb', line 11 def initialize(input = $stdin) @input = input end |
Instance Method Details
#echo(is_on = true, &block) ⇒ Object
Echo given block
20 21 22 23 24 25 26 |
# File 'lib/tty2/reader/mode.rb', line 20 def echo(is_on = true, &block) if is_on || !@input.tty? yield else @input.noecho(&block) end end |
#raw(is_on = true, &block) ⇒ Object
Use raw mode in the given block
33 34 35 36 37 38 39 |
# File 'lib/tty2/reader/mode.rb', line 33 def raw(is_on = true, &block) if is_on && @input.tty? @input.raw(&block) else yield end end |