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