Class: Palaver::PasswordBox

Inherits:
Base
  • Object
show all
Defined in:
lib/palaver/passwordbox.rb

Instance Method Summary collapse

Methods inherited from Base

#height, #text, #width, #with_tempfile

Constructor Details

#initialize(options) ⇒ PasswordBox

Returns a new instance of PasswordBox.



6
7
8
9
10
11
12
13
14
15
# File 'lib/palaver/passwordbox.rb', line 6

def initialize(options)
  super(options)
  @insecure = false

  options.each do |option,value|
    case option
    when :insecure then self.insecure(value)
    end
  end
end

Instance Method Details

#insecure(should_be_insecure = true) ⇒ Object



17
18
19
# File 'lib/palaver/passwordbox.rb', line 17

def insecure(should_be_insecure=true)
  @insecure = should_be_insecure
end

#showObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/palaver/passwordbox.rb', line 22

def show
  answer = nil
  with_tempfile do |fname|
    insecure = @insecure ? "--insecure" : ""
    cmd = "dialog #{insecure} --passwordbox '#@text' #@height #@width 2> #{fname}"
    #puts cmd
    success = system cmd
    if success  then
      answer = File.read(fname)
    end
  end
  return answer      
end