Module: InputModule

Included in:
Workflow
Defined in:
lib/rbbt/util/misc/annotated_module.rb

Instance Method Summary collapse

Instance Method Details

#input(name, type = nil, desc = nil, default = nil, options = nil) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rbbt/util/misc/annotated_module.rb', line 36

def input(name, type = nil, desc = nil, default = nil, options = nil)
  name = name.to_sym
  type = type.to_sym

  @inputs             = [] if @inputs.nil?
  @input_types        = {} if @input_types.nil?
  @input_descriptions = {} if @input_descriptions.nil?
  @input_defaults     = {} if @input_defaults.nil?
  @input_options      = {} if @input_options.nil?
  @required_inputs    = [] if @required_inputs.nil?

  required = Misc.process_options options, :required if options
  required, default = true, nil if default == :required
  @required_inputs << name  if required

  @inputs                   << name
  @input_types[name]        = type unless type.nil?
  @input_descriptions[name] = desc unless desc.nil?
  @input_defaults[name]     = default unless default.nil?
  @input_options[name]      = options unless options.nil?

end