Class: Legion::Extensions::Agentic::Defense::ImmuneResponse::Helpers::ImmuneResponse
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Defense::ImmuneResponse::Helpers::ImmuneResponse
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/defense/immune_response/helpers/immune_response.rb
Constant Summary
Constants included from Constants
Constants::ANTIGEN_TYPES, Constants::DEFAULT_THREAT_LEVEL, Constants::HEALTH_LABELS, Constants::IMMUNITY_BOOST, Constants::IMMUNITY_DECAY, Constants::IMMUNITY_LABELS, Constants::MAX_ANTIBODIES, Constants::MAX_ANTIGENS, Constants::MAX_EXPOSURES, Constants::MAX_RESPONSES, Constants::MEMORY_CELL_THRESHOLD, Constants::REJECTION_THRESHOLD, Constants::RESPONSE_LABELS, Constants::RESPONSE_LEVELS, Constants::THREAT_ESCALATION, Constants::THREAT_LABELS, Constants::TOLERANCE_THRESHOLD
Instance Attribute Summary collapse
-
#action_taken ⇒ Object
readonly
Returns the value of attribute action_taken.
-
#antibody_id ⇒ Object
readonly
Returns the value of attribute antibody_id.
-
#antigen_id ⇒ Object
readonly
Returns the value of attribute antigen_id.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#intensity ⇒ Object
readonly
Returns the value of attribute intensity.
-
#response_level ⇒ Object
readonly
Returns the value of attribute response_level.
Instance Method Summary collapse
- #adaptive? ⇒ Boolean
-
#initialize(antigen_id:, response_level:, antibody_id: nil, intensity: 0.5) ⇒ ImmuneResponse
constructor
A new instance of ImmuneResponse.
- #innate? ⇒ Boolean
- #record_action!(action) ⇒ Object
- #response_label ⇒ Object
- #severe? ⇒ Boolean
- #to_h ⇒ Object
Methods included from Constants
Constructor Details
#initialize(antigen_id:, response_level:, antibody_id: nil, intensity: 0.5) ⇒ ImmuneResponse
Returns a new instance of ImmuneResponse.
17 18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/immune_response.rb', line 17 def initialize(antigen_id:, response_level:, antibody_id: nil, intensity: 0.5) @id = SecureRandom.uuid @antigen_id = antigen_id @antibody_id = antibody_id @response_level = validate_response(response_level) @intensity = intensity.to_f.clamp(0.0, 1.0).round(10) @action_taken = nil @created_at = Time.now.utc end |
Instance Attribute Details
#action_taken ⇒ Object (readonly)
Returns the value of attribute action_taken.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/immune_response.rb', line 14 def action_taken @action_taken end |
#antibody_id ⇒ Object (readonly)
Returns the value of attribute antibody_id.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/immune_response.rb', line 14 def antibody_id @antibody_id end |
#antigen_id ⇒ Object (readonly)
Returns the value of attribute antigen_id.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/immune_response.rb', line 14 def antigen_id @antigen_id end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/immune_response.rb', line 14 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/immune_response.rb', line 14 def id @id end |
#intensity ⇒ Object (readonly)
Returns the value of attribute intensity.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/immune_response.rb', line 14 def intensity @intensity end |
#response_level ⇒ Object (readonly)
Returns the value of attribute response_level.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/immune_response.rb', line 14 def response_level @response_level end |
Instance Method Details
#adaptive? ⇒ Boolean
32 33 34 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/immune_response.rb', line 32 def adaptive? !@antibody_id.nil? end |
#innate? ⇒ Boolean
36 37 38 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/immune_response.rb', line 36 def innate? @antibody_id.nil? end |
#record_action!(action) ⇒ Object
27 28 29 30 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/immune_response.rb', line 27 def record_action!(action) @action_taken = action.to_s self end |
#response_label ⇒ Object
44 45 46 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/immune_response.rb', line 44 def response_label Constants.label_for(RESPONSE_LABELS, @intensity) end |
#severe? ⇒ Boolean
40 41 42 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/immune_response.rb', line 40 def severe? @intensity >= REJECTION_THRESHOLD end |
#to_h ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/immune_response.rb', line 48 def to_h { id: @id, antigen_id: @antigen_id, antibody_id: @antibody_id, response_level: @response_level, intensity: @intensity, response_label: response_label, adaptive: adaptive?, innate: innate?, severe: severe?, action_taken: @action_taken, created_at: @created_at } end |