Class: SetupConfiguration::Parameter
- Inherits:
-
Object
- Object
- SetupConfiguration::Parameter
- Includes:
- Enumerable, ParameterMachineTypeBridge
- Defined in:
- lib/setup_configuration/setup_config.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#dependency ⇒ Object
readonly
Returns the value of attribute dependency.
-
#key ⇒ Object
Returns the value of attribute key.
-
#machine_type ⇒ Object
readonly
Returns the value of attribute machine_type.
-
#number ⇒ Object
Returns the value of attribute number.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
Instance Method Summary collapse
- #<=>(parameter) ⇒ Object
- #depends_on(dependency) ⇒ Object
- #enabled_for_role(*roles) ⇒ Object
- #for_machine_type(machine_type) ⇒ Object
- #has_options(*opt) ⇒ Object
-
#initialize(name, number) ⇒ Parameter
constructor
A new instance of Parameter.
- #param? ⇒ Boolean
Constructor Details
#initialize(name, number) ⇒ Parameter
Returns a new instance of Parameter.
317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/setup_configuration/setup_config.rb', line 317 def initialize(name, number) # depends upon no other parameter @dependency=:none # valid on all machines @machine_type=0 @options=0 @roles=0 @key= name @number=number @role = Roles.new @option = SoftwareOptions.new end |
Instance Attribute Details
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
312 313 314 |
# File 'lib/setup_configuration/setup_config.rb', line 312 def dependency @dependency end |
#key ⇒ Object
Returns the value of attribute key.
310 311 312 |
# File 'lib/setup_configuration/setup_config.rb', line 310 def key @key end |
#machine_type ⇒ Object (readonly)
Returns the value of attribute machine_type.
313 314 315 |
# File 'lib/setup_configuration/setup_config.rb', line 313 def machine_type @machine_type end |
#number ⇒ Object
Returns the value of attribute number.
311 312 313 |
# File 'lib/setup_configuration/setup_config.rb', line 311 def number @number end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
314 315 316 |
# File 'lib/setup_configuration/setup_config.rb', line 314 def @options end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
315 316 317 |
# File 'lib/setup_configuration/setup_config.rb', line 315 def roles @roles end |
Instance Method Details
#<=>(parameter) ⇒ Object
354 355 356 |
# File 'lib/setup_configuration/setup_config.rb', line 354 def <=>(parameter) self.number <=> parameter.number end |
#depends_on(dependency) ⇒ Object
330 331 332 |
# File 'lib/setup_configuration/setup_config.rb', line 330 def depends_on(dependency) @dependency=dependency end |
#enabled_for_role(*roles) ⇒ Object
346 347 348 349 350 351 352 |
# File 'lib/setup_configuration/setup_config.rb', line 346 def enabled_for_role(*roles) # use @roles as initial value: multiple calls to enabled_for_role are possible and result value is chained # (and not reset if using '0' as explicit initial value) @roles = roles.uniq.inject(@roles) do |sum, r| sum + @role.number(r) end end |
#for_machine_type(machine_type) ⇒ Object
334 335 336 |
# File 'lib/setup_configuration/setup_config.rb', line 334 def for_machine_type(machine_type) @machine_type=machine_type end |
#has_options(*opt) ⇒ Object
338 339 340 341 342 343 344 |
# File 'lib/setup_configuration/setup_config.rb', line 338 def (*opt) # use @options as initial value: multiple calls to has_options are possible and result value is chained # (and not reset if using '0' as explicit initial value) @options = opt.uniq.inject(@options) do |sum, o| sum + @option.number(o) end end |
#param? ⇒ Boolean
358 359 360 |
# File 'lib/setup_configuration/setup_config.rb', line 358 def param? true end |