Class: Palaver::DialogFactory
- Inherits:
-
Object
- Object
- Palaver::DialogFactory
- Defined in:
- lib/palaver/dialog_factory.rb
Constant Summary collapse
- @@dialog_types =
{ :calendar => Calendar, :checklist => Checklist, :radiolist => Radiolist, :menu => Menu, :yesno => YesNo, :textbox => TextBox, :msgbox => MsgBox, :inputbox => InputBox, :infobox => InfoBox, :pause => Pause, :passwordbox => PasswordBox, :dselect => DSelect, :fselect => FSelect, :form => Form, :passwordform => PasswordForm, :gauge => Gauge }
Instance Method Summary collapse
- #common_options ⇒ Object
-
#initialize(*options) ⇒ DialogFactory
constructor
A new instance of DialogFactory.
Constructor Details
#initialize(*options) ⇒ DialogFactory
Returns a new instance of DialogFactory.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/palaver/dialog_factory.rb', line 25 def initialize(*) .each do |option| case option when :insecure then @insecure = true when :ascii_lines then @ascii_lines = true when :no_lines then @no_lines = true end if option.class == Hash then option.each do |k,v| case k when :aspect then @aspect = v when :backtitle then @backtitle = v when :begin then @begin = v when :cancel_label then @cancel_label = v end end end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(methodsym, *args, &block) ⇒ Object (private)
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/palaver/dialog_factory.rb', line 60 def method_missing(methodsym, *args, &block) if @@dialog_types.has_key? methodsym then c = @@dialog_types[methodsym] = args.size == 1 ? args[0] : {} [:common_options] = return make_dialog(c, , &block) else raise NoMethodError.new("Undefined method: #{methodsym} for #{self}", methodsym) end end |
Instance Method Details
#common_options ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/palaver/dialog_factory.rb', line 46 def = [] .push("--insecure") if @insecure .push("--ascii-lines") if @ascii_lines .push("--no-lines") if @no_lines .push("--aspect #@aspect") if @aspect .push("--backtitle '#@backtitle'") if @backtitle .push("--begin #{@begin[0]} #{@begin[1]}") if @begin .push("--cancel-label '#@cancel_label'") if @cancel_label return .join(" ") end |