Class: DecisionAgent::Evaluation
- Inherits:
-
Object
- Object
- DecisionAgent::Evaluation
- Defined in:
- lib/decision_agent/evaluation.rb
Overview
Single evaluation produced by an evaluator: a suggested decision, weight, reason, and optional metadata.
Instance Attribute Summary collapse
-
#decision ⇒ Object
readonly
Returns the value of attribute decision.
-
#evaluator_name ⇒ Object
readonly
Returns the value of attribute evaluator_name.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
True if other is an Evaluation with same attributes.
-
#initialize(decision:, weight:, reason:, evaluator_name:, metadata: {}) ⇒ Evaluation
constructor
A new instance of Evaluation.
-
#to_h ⇒ Hash
Symbol-keyed hash of decision, weight, reason, evaluator_name, metadata.
Constructor Details
#initialize(decision:, weight:, reason:, evaluator_name:, metadata: {}) ⇒ Evaluation
Returns a new instance of Evaluation.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/decision_agent/evaluation.rb', line 14 def initialize(decision:, weight:, reason:, evaluator_name:, metadata: {}) validate_weight!(weight) @decision = decision.to_s.freeze @weight = weight.to_f @reason = reason.to_s.freeze @evaluator_name = evaluator_name.to_s.freeze @metadata = deep_freeze() freeze end |
Instance Attribute Details
#decision ⇒ Object (readonly)
Returns the value of attribute decision.
6 7 8 |
# File 'lib/decision_agent/evaluation.rb', line 6 def decision @decision end |
#evaluator_name ⇒ Object (readonly)
Returns the value of attribute evaluator_name.
6 7 8 |
# File 'lib/decision_agent/evaluation.rb', line 6 def evaluator_name @evaluator_name end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
6 7 8 |
# File 'lib/decision_agent/evaluation.rb', line 6 def @metadata end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
6 7 8 |
# File 'lib/decision_agent/evaluation.rb', line 6 def reason @reason end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
6 7 8 |
# File 'lib/decision_agent/evaluation.rb', line 6 def weight @weight end |
Instance Method Details
#==(other) ⇒ Boolean
Returns true if other is an Evaluation with same attributes.
39 40 41 42 43 44 45 46 |
# File 'lib/decision_agent/evaluation.rb', line 39 def ==(other) other.is_a?(Evaluation) && @decision == other.decision && @weight == other.weight && @reason == other.reason && @evaluator_name == other.evaluator_name && @metadata == other. end |
#to_h ⇒ Hash
Returns Symbol-keyed hash of decision, weight, reason, evaluator_name, metadata.
27 28 29 30 31 32 33 34 35 |
# File 'lib/decision_agent/evaluation.rb', line 27 def to_h { decision: @decision, weight: @weight, reason: @reason, evaluator_name: @evaluator_name, metadata: @metadata } end |