Class: Legion::Extensions::Agentic::Attention::Synesthesia::Helpers::SensoryMapping

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from Constants

label_for

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_countObject (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_atObject (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

#idObject (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_atObject (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_patternObject (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_modalityObject (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

#strengthObject (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_modalityObject (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_patternObject (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

Returns:

  • (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_labelObject



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_hObject



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