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.



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

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.



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

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.



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

def success; end