Class: Palaver::InputBox

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

Instance Method Summary collapse

Methods inherited from Base

#height, #text, #width, #with_tempfile

Constructor Details

#initialize(options) ⇒ InputBox

Returns a new instance of InputBox.



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

def initialize(options)
  super(options)
  @initial = nil

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

end

Instance Method Details

#initial(text) ⇒ Object



18
19
20
# File 'lib/palaver/inputbox.rb', line 18

def initial(text)
  @initial = text
end

#showObject



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

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