Class: SetupConfiguration::ParameterFactory
- Inherits:
-
Object
- Object
- SetupConfiguration::ParameterFactory
- Defined in:
- lib/setup_configuration/setup_config.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
-
#drive(drive, number, added_props = [], ¶meter_def) ⇒ Object
Additional block is allowed, it may contain call for_machine_type and depends_on.
-
#initialize ⇒ ParameterFactory
constructor
A new instance of ParameterFactory.
- #param(parameter, number, ¶meter_def) ⇒ Object
- #param_ref(parameter) ⇒ Object
Constructor Details
#initialize ⇒ ParameterFactory
Returns a new instance of ParameterFactory.
223 224 225 |
# File 'lib/setup_configuration/setup_config.rb', line 223 def initialize self.params= [] end |
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
221 222 223 |
# File 'lib/setup_configuration/setup_config.rb', line 221 def params @params end |
Instance Method Details
#drive(drive, number, added_props = [], ¶meter_def) ⇒ Object
Additional block is allowed, it may contain call for_machine_type and depends_on. This additional information is applied only to generated parameter <drive>_selection. The additional for_machine_type is also applied to other generated parameters.
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/setup_configuration/setup_config.rb', line 247 def drive(drive, number, added_props=[], ¶meter_def) key = symbol(drive, "drive") drive_selection = symbol(key, "selection") drive_param=param(drive_selection, number) drive_param.instance_eval(¶meter_def) if parameter_def properties=[%w(distance revolution), %w(gear in), %w(gear out), "length", "motortype"] properties += added_props if added_props properties.each_with_index do |prop, index| parameter = param(symbol(key, *prop), number + index + 1) { depends_on drive_selection } parameter.for_machine_type(drive_param.machine_type) end end |
#param(parameter, number, ¶meter_def) ⇒ Object
227 228 229 230 231 232 233 |
# File 'lib/setup_configuration/setup_config.rb', line 227 def param(parameter, number, ¶meter_def) # evaluate given block in Parameter context and return new parameter p = Parameter.new(parameter, number) p.instance_eval(¶meter_def) if parameter_def params << p p end |
#param_ref(parameter) ⇒ Object
235 236 237 238 |
# File 'lib/setup_configuration/setup_config.rb', line 235 def param_ref(parameter) p = ParameterReference.new(parameter) params << p end |