Class: Legion::Extensions::Agentic::Defense::ImmuneResponse::Helpers::Antibody
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Defense::ImmuneResponse::Helpers::Antibody
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/defense/immune_response/helpers/antibody.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
-
#antigen_type ⇒ Object
readonly
Returns the value of attribute antigen_type.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#immunity_level ⇒ Object
readonly
Returns the value of attribute immunity_level.
-
#match_count ⇒ Object
readonly
Returns the value of attribute match_count.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
Instance Method Summary collapse
- #decay! ⇒ Object
- #effective? ⇒ Boolean
- #immunity_label ⇒ Object
-
#initialize(antigen_type:, signature:, immunity_level: 0.3) ⇒ Antibody
constructor
A new instance of Antibody.
- #matches?(antigen) ⇒ Boolean
- #memory_cell? ⇒ Boolean
- #strengthen!(amount = IMMUNITY_BOOST) ⇒ Object
- #to_h ⇒ Object
Methods included from Constants
Constructor Details
#initialize(antigen_type:, signature:, immunity_level: 0.3) ⇒ Antibody
Returns a new instance of Antibody.
17 18 19 20 21 22 23 24 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antibody.rb', line 17 def initialize(antigen_type:, signature:, immunity_level: 0.3) @id = SecureRandom.uuid @antigen_type = antigen_type.to_sym @signature = signature @immunity_level = immunity_level.to_f.clamp(0.0, 1.0).round(10) @match_count = 0 @created_at = Time.now.utc end |
Instance Attribute Details
#antigen_type ⇒ Object (readonly)
Returns the value of attribute antigen_type.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antibody.rb', line 14 def antigen_type @antigen_type end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antibody.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/antibody.rb', line 14 def id @id end |
#immunity_level ⇒ Object (readonly)
Returns the value of attribute immunity_level.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antibody.rb', line 14 def immunity_level @immunity_level end |
#match_count ⇒ Object (readonly)
Returns the value of attribute match_count.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antibody.rb', line 14 def match_count @match_count end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
14 15 16 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antibody.rb', line 14 def signature @signature end |
Instance Method Details
#decay! ⇒ Object
32 33 34 35 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antibody.rb', line 32 def decay! @immunity_level = (@immunity_level - IMMUNITY_DECAY).clamp(0.0, 1.0).round(10) self end |
#effective? ⇒ Boolean
45 46 47 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antibody.rb', line 45 def effective? @immunity_level >= 0.5 end |
#immunity_label ⇒ Object
49 50 51 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antibody.rb', line 49 def immunity_label Constants.label_for(IMMUNITY_LABELS, @immunity_level) end |
#matches?(antigen) ⇒ Boolean
37 38 39 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antibody.rb', line 37 def matches?(antigen) antigen.antigen_type == @antigen_type end |
#memory_cell? ⇒ Boolean
41 42 43 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antibody.rb', line 41 def memory_cell? @immunity_level >= MEMORY_CELL_THRESHOLD end |
#strengthen!(amount = IMMUNITY_BOOST) ⇒ Object
26 27 28 29 30 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antibody.rb', line 26 def strengthen!(amount = IMMUNITY_BOOST) @match_count += 1 @immunity_level = (@immunity_level + amount).clamp(0.0, 1.0).round(10) self end |
#to_h ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/legion/extensions/agentic/defense/immune_response/helpers/antibody.rb', line 53 def to_h { id: @id, antigen_type: @antigen_type, signature: @signature, immunity_level: @immunity_level, immunity_label: immunity_label, match_count: @match_count, memory_cell: memory_cell?, effective: effective?, created_at: @created_at } end |