Class: Musa::Darwin::Darwin::Measure
- Inherits:
-
Object
- Object
- Musa::Darwin::Darwin::Measure
- Defined in:
- lib/musa-dsl/generative/darwin.rb
Instance Attribute Summary collapse
-
#dimensions ⇒ Object
readonly
Returns the value of attribute dimensions.
-
#features ⇒ Object
readonly
Returns the value of attribute features.
-
#normalized_dimensions ⇒ Object
readonly
Returns the value of attribute normalized_dimensions.
Instance Method Summary collapse
- #died? ⇒ Boolean
- #evaluate_weight(weights) ⇒ Object
-
#initialize(features, dimensions, died) ⇒ Measure
constructor
A new instance of Measure.
- #inspect ⇒ Object (also: #to_s)
Constructor Details
#initialize(features, dimensions, died) ⇒ Measure
Returns a new instance of Measure.
118 119 120 121 122 123 124 |
# File 'lib/musa-dsl/generative/darwin.rb', line 118 def initialize(features, dimensions, died) @features = features @dimensions = dimensions @died = died @normalized_dimensions = {} end |
Instance Attribute Details
#dimensions ⇒ Object (readonly)
Returns the value of attribute dimensions.
116 117 118 |
# File 'lib/musa-dsl/generative/darwin.rb', line 116 def dimensions @dimensions end |
#features ⇒ Object (readonly)
Returns the value of attribute features.
116 117 118 |
# File 'lib/musa-dsl/generative/darwin.rb', line 116 def features @features end |
#normalized_dimensions ⇒ Object (readonly)
Returns the value of attribute normalized_dimensions.
116 117 118 |
# File 'lib/musa-dsl/generative/darwin.rb', line 116 def normalized_dimensions @normalized_dimensions end |
Instance Method Details
#died? ⇒ Boolean
126 127 128 |
# File 'lib/musa-dsl/generative/darwin.rb', line 126 def died? @died end |
#evaluate_weight(weights) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/musa-dsl/generative/darwin.rb', line 130 def evaluate_weight(weights) total = 0.0 unless @died weights.each do |name, weight| total += @normalized_dimensions[name] * weight if @normalized_dimensions.key? name total += weight if @features[name] end end total end |
#inspect ⇒ Object Also known as: to_s
143 144 145 |
# File 'lib/musa-dsl/generative/darwin.rb', line 143 def inspect "Measure features=#{@features.collect { |k, _v| k }} dimensions=#{@normalized_dimensions.collect { |k, v| [k, [@dimensions[k].round(5), v.round(2)]] }.to_h}" end |