Class: Rabbit::PasswordReader
- Inherits:
-
Object
- Object
- Rabbit::PasswordReader
- Defined in:
- lib/rabbit/password-reader.rb
Instance Method Summary collapse
-
#initialize(prompt) ⇒ PasswordReader
constructor
A new instance of PasswordReader.
- #read ⇒ Object
Constructor Details
#initialize(prompt) ⇒ PasswordReader
Returns a new instance of PasswordReader.
19 20 21 |
# File 'lib/rabbit/password-reader.rb', line 19 def initialize(prompt) @prompt = prompt end |
Instance Method Details
#read ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rabbit/password-reader.rb', line 23 def read print(@prompt) system("/bin/stty -echo") if $stdin.tty? $stdin.gets.chomp ensure if $stdin.tty? system("/bin/stty echo") puts end end |