Class: Palaver::BaseForm

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

Direct Known Subclasses

Form, PasswordForm

Defined Under Namespace

Classes: Entry

Instance Method Summary collapse

Methods inherited from Base

#height, #text, #width, #with_tempfile

Constructor Details

#initialize(dialogcmd, options) ⇒ BaseForm

Returns a new instance of BaseForm.



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

def initialize(dialogcmd, options)
  super(options)
  @dialogcmd = dialogcmd
  @entries = []
  @form_height = nil
  @simple_display_width = nil
  @simple_text_length = nil
end

Instance Method Details

#showObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/palaver/baseform.rb', line 16

def show
  text_width = @entries.map { |e| e.text_width }.max
  @entries.each { |e| e.update_value_x text_width }
  
  cmd_intro = "dialog #@common_options --#@dialogcmd '#@text' #@height #@width #@form_height "
  cmd_entries = @entries.map { |e| e.to_cmd_s }.join(' ')

  result = nil
  with_tempfile do |tfpath|
    cmd = "#{cmd_intro} #{cmd_entries} 2> #{tfpath}"
    success = system cmd
    result = read_dialog_output tfpath
  end
  
  return result
end