Method: IO#getpass
- Defined in:
- console/console.c
#getpass(prompt = nil) ⇒ String
Reads and returns a line without echo back. Prints prompt unless it is nil.
The newline character that terminates the read line is removed from the returned string, see String#chomp!.
You must require ‘io/console’ to use this method.
require 'io/console'
IO::console.getpass("Enter password:")
Enter password:
# => "mypassword"
1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 |
# File 'console/console.c', line 1794 static VALUE console_getpass(int argc, VALUE *argv, VALUE io) { VALUE str, wio; rb_check_arity(argc, 0, 1); wio = rb_io_get_write_io(io); if (wio == io && io == rb_stdin) wio = rb_stderr; prompt(argc, argv, wio); rb_io_flush(wio); str = rb_ensure(getpass_call, io, puts_call, wio); return str_chomp(str); } |