Class: SetupConfiguration::Parameter

Inherits:
Object
  • Object
show all
Includes:
Enumerable, ParameterMachineTypeBridge
Defined in:
lib/setup_configuration/setup_config.rb

Direct Known Subclasses

Legacy::Parameter

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dependencyObject (readonly)

Returns the value of attribute dependency.



312
313
314
# File 'lib/setup_configuration/setup_config.rb', line 312

def dependency
  @dependency
end

#keyObject

Returns the value of attribute key.



310
311
312
# File 'lib/setup_configuration/setup_config.rb', line 310

def key
  @key
end

#machine_typeObject (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

#numberObject

Returns the value of attribute number.



311
312
313
# File 'lib/setup_configuration/setup_config.rb', line 311

def number
  @number
end

#optionsObject (readonly)

Returns the value of attribute options.



314
315
316
# File 'lib/setup_configuration/setup_config.rb', line 314

def options
  @options
end

#rolesObject (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 has_options(*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

Returns:

  • (Boolean)


358
359
360
# File 'lib/setup_configuration/setup_config.rb', line 358

def param?
  true
end