Class: SSHwrap::Prompter
- Inherits:
-
Object
- Object
- SSHwrap::Prompter
- Defined in:
- lib/sshwrap/prompter.rb
Instance Attribute Summary collapse
-
#passwords ⇒ Object
readonly
Returns the value of attribute passwords.
Instance Method Summary collapse
-
#initialize ⇒ Prompter
constructor
A new instance of Prompter.
- #prompt(prompt, echo = false) ⇒ Object
Constructor Details
#initialize ⇒ Prompter
Returns a new instance of Prompter.
3 4 5 6 |
# File 'lib/sshwrap/prompter.rb', line 3 def initialize @mutex = Mutex.new @passwords = {} end |
Instance Attribute Details
#passwords ⇒ Object (readonly)
Returns the value of attribute passwords.
2 3 4 |
# File 'lib/sshwrap/prompter.rb', line 2 def passwords @passwords end |
Instance Method Details
#prompt(prompt, echo = false) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/sshwrap/prompter.rb', line 7 def prompt(prompt, echo=false) @mutex.synchronize do if !@passwords[prompt] @passwords[prompt] = ask(prompt) { |q| q.echo = echo } end end @passwords[prompt] end |