Class: SSHwrap::Prompter

Inherits:
Object
  • Object
show all
Defined in:
lib/sshwrap/prompter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePrompter

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

#passwordsObject (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