Class: TTY::Prompt::Reader::Mode Private
- Inherits:
-
Object
- Object
- TTY::Prompt::Reader::Mode
- Defined in:
- lib/tty/prompt/reader/mode.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.
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
12 13 14 |
# File 'lib/tty/prompt/reader/mode.rb', line 12 def initialize(input = $stdin) @input = input end |
Instance Method Details
#echo(is_on = true, &block) ⇒ Object
Echo given block
21 22 23 24 25 26 27 |
# File 'lib/tty/prompt/reader/mode.rb', line 21 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
34 35 36 37 38 39 40 |
# File 'lib/tty/prompt/reader/mode.rb', line 34 def raw(is_on = true, &block) if is_on && @input.tty? @input.raw(&block) else yield end end |