class TTY::Prompt::Reader::Mode
Public Class Methods
new(input = $stdin)
click to toggle source
Initialize a Terminal
@api public
# File lib/tty/prompt/reader/mode.rb, line 12 def initialize(input = $stdin) @input = input end
Public Instance Methods
echo(is_on = true) { || ... }
click to toggle source
Echo given block
@param [Boolean] is_on
@api public
# 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) { || ... }
click to toggle source
Use raw mode in the given block
@param [Boolean] is_on
@api public
# 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