Sha256: 1a432b159b1329ac7734f3b4b7d7cdba48569c0aa6d5d98ab6bfd2147d679346
Contents?: true
Size: 480 Bytes
Versions: 9
Compression:
Stored size: 480 Bytes
Contents
class IO def get_password(out: $stderr) result = '' noecho do while char = getch case char when /[\r\n]/ break when /[\e\b\x7f]/ result.replace result.chop out.write "\b \b" when /[\x3\x1A]/ # interrupt, background out.write "\nOk, aborting\n" abort else result << char out.write '*' end end end out.write "\n" result end end
Version data entries
9 entries across 9 versions & 1 rubygems