Class: Rabbit::PasswordReader

Inherits:
Object
  • Object
show all
Defined in:
lib/rabbit/password-reader.rb

Instance Method Summary collapse

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

#readObject



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