Class: Palaver::PathSelect
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ PathSelect
constructor
A new instance of PathSelect.
- #path(str) ⇒ Object
- #show ⇒ Object
Methods inherited from Base
#height, #text, #width, #with_tempfile
Constructor Details
#initialize(options = {}) ⇒ PathSelect
Returns a new instance of PathSelect.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/palaver/pathselect.rb', line 6 def initialize(={}) super() @path = nil .each do |option,value| case option when :path then self.path(value) end end end |
Instance Method Details
#path(str) ⇒ Object
18 19 20 |
# File 'lib/palaver/pathselect.rb', line 18 def path(str) @path = str end |
#show ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/palaver/pathselect.rb', line 22 def show raise "Can't open a #{dialog_name} dialog with a path" if not @path chosen_file = nil with_tempfile do |tfpath| cmd = "dialog #@common_options --#{dialog_name} '#@path' #@height #@width 2> #{tfpath}" puts cmd success = system cmd chosen_file = File.read(tfpath) if success end return chosen_file end |