Class: Legion::Extensions::Agentic::Self::Anosognosia::Helpers::CognitiveDeficit
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Self::Anosognosia::Helpers::CognitiveDeficit
- Defined in:
- lib/legion/extensions/agentic/self/anosognosia/helpers/cognitive_deficit.rb
Instance Attribute Summary collapse
-
#acknowledged ⇒ Object
readonly
Returns the value of attribute acknowledged.
-
#acknowledged_at ⇒ Object
readonly
Returns the value of attribute acknowledged_at.
-
#deficit_type ⇒ Object
readonly
Returns the value of attribute deficit_type.
-
#discovered_at ⇒ Object
readonly
Returns the value of attribute discovered_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
Instance Method Summary collapse
- #acknowledge! ⇒ Object
-
#initialize(domain:, deficit_type:, severity:, acknowledged: false) ⇒ CognitiveDeficit
constructor
A new instance of CognitiveDeficit.
- #severity_label ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(domain:, deficit_type:, severity:, acknowledged: false) ⇒ CognitiveDeficit
Returns a new instance of CognitiveDeficit.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/self/anosognosia/helpers/cognitive_deficit.rb', line 15 def initialize(domain:, deficit_type:, severity:, acknowledged: false) validate_deficit_type!(deficit_type) @id = SecureRandom.uuid @domain = domain @deficit_type = deficit_type @severity = severity.clamp(0.0, 1.0) @acknowledged = acknowledged @discovered_at = Time.now.utc @acknowledged_at = nil end |
Instance Attribute Details
#acknowledged ⇒ Object (readonly)
Returns the value of attribute acknowledged.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/anosognosia/helpers/cognitive_deficit.rb', line 12 def acknowledged @acknowledged end |
#acknowledged_at ⇒ Object (readonly)
Returns the value of attribute acknowledged_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/anosognosia/helpers/cognitive_deficit.rb', line 12 def acknowledged_at @acknowledged_at end |
#deficit_type ⇒ Object (readonly)
Returns the value of attribute deficit_type.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/anosognosia/helpers/cognitive_deficit.rb', line 12 def deficit_type @deficit_type end |
#discovered_at ⇒ Object (readonly)
Returns the value of attribute discovered_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/anosognosia/helpers/cognitive_deficit.rb', line 12 def discovered_at @discovered_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/anosognosia/helpers/cognitive_deficit.rb', line 12 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/anosognosia/helpers/cognitive_deficit.rb', line 12 def id @id end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/anosognosia/helpers/cognitive_deficit.rb', line 12 def severity @severity end |
Instance Method Details
#acknowledge! ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/legion/extensions/agentic/self/anosognosia/helpers/cognitive_deficit.rb', line 27 def acknowledge! return false if @acknowledged @acknowledged = true @acknowledged_at = Time.now.utc true end |
#severity_label ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/legion/extensions/agentic/self/anosognosia/helpers/cognitive_deficit.rb', line 35 def severity_label case @severity when (0.8..1.0) then :severe when (0.6...0.8) then :high when (0.4...0.6) then :moderate when (0.2...0.4) then :low else :minimal end end |
#to_h ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/legion/extensions/agentic/self/anosognosia/helpers/cognitive_deficit.rb', line 45 def to_h { id: @id, domain: @domain, deficit_type: @deficit_type, severity: @severity.round(10), severity_label: severity_label, acknowledged: @acknowledged, discovered_at: @discovered_at, acknowledged_at: @acknowledged_at } end |