Class: Palaver::InputBox
Instance Method Summary collapse
- #initial(text) ⇒ Object
-
#initialize(options) ⇒ InputBox
constructor
A new instance of InputBox.
- #show ⇒ Object
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() super() @initial = nil .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 |
#show ⇒ Object
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 |