Class: DecisionAgent::Explainability::ConditionTrace

Inherits:
Object
  • Object
show all
Defined in:
lib/decision_agent/explainability/condition_trace.rb

Overview

Represents a single condition evaluation with its result and values

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field:, operator:, expected_value:, actual_value:, result:, description: nil) ⇒ ConditionTrace

Returns a new instance of ConditionTrace.



9
10
11
12
13
14
15
16
17
# File 'lib/decision_agent/explainability/condition_trace.rb', line 9

def initialize(field:, operator:, expected_value:, actual_value:, result:, description: nil)
  @field = field.to_s.freeze
  @operator = operator.to_s.freeze
  @expected_value = expected_value
  @actual_value = actual_value
  @result = result
  @description = description ? description.to_s.freeze : generate_description
  freeze
end

Instance Attribute Details

#actual_valueObject (readonly)

Returns the value of attribute actual_value.



7
8
9
# File 'lib/decision_agent/explainability/condition_trace.rb', line 7

def actual_value
  @actual_value
end

#descriptionObject (readonly)

Returns the value of attribute description.



7
8
9
# File 'lib/decision_agent/explainability/condition_trace.rb', line 7

def description
  @description
end

#expected_valueObject (readonly)

Returns the value of attribute expected_value.



7
8
9
# File 'lib/decision_agent/explainability/condition_trace.rb', line 7

def expected_value
  @expected_value
end

#fieldObject (readonly)

Returns the value of attribute field.



7
8
9
# File 'lib/decision_agent/explainability/condition_trace.rb', line 7

def field
  @field
end

#operatorObject (readonly)

Returns the value of attribute operator.



7
8
9
# File 'lib/decision_agent/explainability/condition_trace.rb', line 7

def operator
  @operator
end

#resultObject (readonly)

Returns the value of attribute result.



7
8
9
# File 'lib/decision_agent/explainability/condition_trace.rb', line 7

def result
  @result
end

Instance Method Details

#failed?Boolean

Returns:



23
24
25
# File 'lib/decision_agent/explainability/condition_trace.rb', line 23

def failed?
  @result == false
end

#passed?Boolean

Returns:



19
20
21
# File 'lib/decision_agent/explainability/condition_trace.rb', line 19

def passed?
  @result == true
end

#to_hObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/decision_agent/explainability/condition_trace.rb', line 31

def to_h
  {
    field: @field,
    operator: @operator,
    expected_value: @expected_value,
    actual_value: @actual_value,
    result: @result,
    description: @description
  }
end

#to_sObject



27
28
29
# File 'lib/decision_agent/explainability/condition_trace.rb', line 27

def to_s
  @description
end