Class: Net::SSH::Prompt::Prompter

Inherits:
Object
  • Object
show all
Defined in:
lib/net/ssh/prompt.rb

Overview

default prompt object implementation. More sophisticated implemenetations might implement caching.

Instance Method Summary collapse

Constructor Details

#initialize(info) ⇒ Prompter

Returns a new instance of Prompter.


33
34
35
36
37
38
# File 'lib/net/ssh/prompt.rb', line 33

def initialize(info)
  if info[:type] == 'keyboard-interactive'
    $stdout.puts(info[:name]) unless info[:name].empty?
    $stdout.puts(info[:instruction]) unless info[:instruction].empty?
  end
end

Instance Method Details

#ask(prompt, echo = true) ⇒ Object

ask input from user, a prompter might ask for multiple inputs (like user and password) in a single session.


42
43
44
45
46
47
48
# File 'lib/net/ssh/prompt.rb', line 42

def ask(prompt, echo=true)
  $stdout.print(prompt)
  $stdout.flush
  ret = $stdin.noecho(&:gets).chomp
  $stdout.print("\n")
  ret
end

#successObject

success method will be called when the password was accepted It's a good time to save password asked to a cache.


52
# File 'lib/net/ssh/prompt.rb', line 52

def success; end