Class: Laborantin::ParameterRange
- Inherits:
-
Object
- Object
- Laborantin::ParameterRange
- Includes:
- Metaprog::Describable
- Defined in:
- lib/laborantin/core/parameter.rb
Overview
A ParameterRange instance is more or less a wrapper over an Array of allowed values.
Instance Attribute Summary collapse
-
#name ⇒ Object
The name of the parameter (should be unique in a Scenario’s parameters) Usually a symbol.
Attributes included from Metaprog::Describable
Instance Method Summary collapse
-
#each ⇒ Object
Iterates on allowed values for this parameter.
-
#initialize(name) ⇒ ParameterRange
constructor
initialize a new instance with the desired name.
-
#values(*args) ⇒ Object
Sets the allowed values.
Constructor Details
#initialize(name) ⇒ ParameterRange
initialize a new instance with the desired name
38 39 40 41 42 |
# File 'lib/laborantin/core/parameter.rb', line 38 def initialize(name) @name = name @values = [] @description = '' end |
Instance Attribute Details
#name ⇒ Object
The name of the parameter (should be unique in a Scenario’s parameters) Usually a symbol.
35 36 37 |
# File 'lib/laborantin/core/parameter.rb', line 35 def name @name end |
Instance Method Details
#each ⇒ Object
Iterates on allowed values for this parameter.
52 53 54 55 56 |
# File 'lib/laborantin/core/parameter.rb', line 52 def each @values.each do |v| yield v end end |
#values(*args) ⇒ Object
Sets the allowed values. Currently only supports Array like. It is planned to support Iterable, but deterministic ones only.
46 47 48 49 |
# File 'lib/laborantin/core/parameter.rb', line 46 def values(*args) @values = args.flatten unless args.empty? @values end |