Class: Legion::Extensions::Agentic::Attention::Synesthesia::Helpers::SensoryMapping
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Attention::Synesthesia::Helpers::SensoryMapping
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/attention/synesthesia/helpers/sensory_mapping.rb
Constant Summary
Constants included from Constants
Constants::DEFAULT_STRENGTH, Constants::INTENSITY_LABELS, Constants::MAX_EVENTS, Constants::MAX_MAPPINGS, Constants::MODALITIES, Constants::RICHNESS_LABELS, Constants::STRENGTH_BOOST, Constants::STRENGTH_DECAY, Constants::STRENGTH_LABELS, Constants::TRIGGER_THRESHOLD
Instance Attribute Summary collapse
-
#activation_count ⇒ Object
readonly
Returns the value of attribute activation_count.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#last_activated_at ⇒ Object
readonly
Returns the value of attribute last_activated_at.
-
#response_pattern ⇒ Object
readonly
Returns the value of attribute response_pattern.
-
#source_modality ⇒ Object
readonly
Returns the value of attribute source_modality.
-
#strength ⇒ Object
readonly
Returns the value of attribute strength.
-
#target_modality ⇒ Object
readonly
Returns the value of attribute target_modality.
-
#trigger_pattern ⇒ Object
readonly
Returns the value of attribute trigger_pattern.
Instance Method Summary collapse
- #activate! ⇒ Object
- #active? ⇒ Boolean
- #decay! ⇒ Object
-
#initialize(source_modality:, target_modality:, trigger_pattern:, response_pattern:, strength: DEFAULT_STRENGTH) ⇒ SensoryMapping
constructor
A new instance of SensoryMapping.
- #strength_label ⇒ Object
- #to_h ⇒ Object
Methods included from Constants
Constructor Details
#initialize(source_modality:, target_modality:, trigger_pattern:, response_pattern:, strength: DEFAULT_STRENGTH) ⇒ SensoryMapping
Returns a new instance of SensoryMapping.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/legion/extensions/agentic/attention/synesthesia/helpers/sensory_mapping.rb', line 18 def initialize(source_modality:, target_modality:, trigger_pattern:, response_pattern:, strength: DEFAULT_STRENGTH) @id = SecureRandom.uuid @source_modality = source_modality @target_modality = target_modality @trigger_pattern = trigger_pattern @response_pattern = response_pattern @strength = strength.clamp(0.0, 1.0) @activation_count = 0 @created_at = Time.now.utc @last_activated_at = nil end |
Instance Attribute Details
#activation_count ⇒ Object (readonly)
Returns the value of attribute activation_count.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/synesthesia/helpers/sensory_mapping.rb', line 14 def activation_count @activation_count end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/synesthesia/helpers/sensory_mapping.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/attention/synesthesia/helpers/sensory_mapping.rb', line 14 def id @id end |
#last_activated_at ⇒ Object (readonly)
Returns the value of attribute last_activated_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/synesthesia/helpers/sensory_mapping.rb', line 14 def last_activated_at @last_activated_at end |
#response_pattern ⇒ Object (readonly)
Returns the value of attribute response_pattern.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/synesthesia/helpers/sensory_mapping.rb', line 14 def response_pattern @response_pattern end |
#source_modality ⇒ Object (readonly)
Returns the value of attribute source_modality.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/synesthesia/helpers/sensory_mapping.rb', line 14 def source_modality @source_modality end |
#strength ⇒ Object (readonly)
Returns the value of attribute strength.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/synesthesia/helpers/sensory_mapping.rb', line 14 def strength @strength end |
#target_modality ⇒ Object (readonly)
Returns the value of attribute target_modality.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/synesthesia/helpers/sensory_mapping.rb', line 14 def target_modality @target_modality end |
#trigger_pattern ⇒ Object (readonly)
Returns the value of attribute trigger_pattern.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/synesthesia/helpers/sensory_mapping.rb', line 14 def trigger_pattern @trigger_pattern end |
Instance Method Details
#activate! ⇒ Object
31 32 33 34 35 |
# File 'lib/legion/extensions/agentic/attention/synesthesia/helpers/sensory_mapping.rb', line 31 def activate! @activation_count += 1 @last_activated_at = Time.now.utc @strength = (@strength + STRENGTH_BOOST).clamp(0.0, 1.0).round(10) end |
#active? ⇒ Boolean
41 42 43 |
# File 'lib/legion/extensions/agentic/attention/synesthesia/helpers/sensory_mapping.rb', line 41 def active? @strength >= TRIGGER_THRESHOLD end |
#decay! ⇒ Object
37 38 39 |
# File 'lib/legion/extensions/agentic/attention/synesthesia/helpers/sensory_mapping.rb', line 37 def decay! @strength = (@strength - STRENGTH_DECAY).clamp(0.0, 1.0).round(10) end |
#strength_label ⇒ Object
45 46 47 |
# File 'lib/legion/extensions/agentic/attention/synesthesia/helpers/sensory_mapping.rb', line 45 def strength_label Constants.label_for(STRENGTH_LABELS, @strength) end |
#to_h ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/legion/extensions/agentic/attention/synesthesia/helpers/sensory_mapping.rb', line 49 def to_h { id: @id, source_modality: @source_modality, target_modality: @target_modality, trigger_pattern: @trigger_pattern, response_pattern: @response_pattern, strength: @strength, activation_count: @activation_count, strength_label: strength_label, active: active?, created_at: @created_at, last_activated_at: @last_activated_at } end |