Class: Legion::Extensions::Agentic::Memory::Nostalgia::Helpers::NostalgiaEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgia_event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(memory_id:, trigger:, intensity:, effect_on_mood: 0.0) ⇒ NostalgiaEvent

Returns a new instance of NostalgiaEvent.



14
15
16
17
18
19
20
21
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgia_event.rb', line 14

def initialize(memory_id:, trigger:, intensity:, effect_on_mood: 0.0)
  @id            = ::SecureRandom.uuid
  @memory_id     = memory_id
  @trigger       = trigger
  @intensity     = intensity.clamp(0.0, 1.0)
  @effect_on_mood = effect_on_mood.clamp(-1.0, 1.0)
  @occurred_at = Time.now.utc
end

Instance Attribute Details

#effect_on_moodObject (readonly)

Returns the value of attribute effect_on_mood.



12
13
14
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgia_event.rb', line 12

def effect_on_mood
  @effect_on_mood
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgia_event.rb', line 12

def id
  @id
end

#intensityObject (readonly)

Returns the value of attribute intensity.



12
13
14
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgia_event.rb', line 12

def intensity
  @intensity
end

#memory_idObject (readonly)

Returns the value of attribute memory_id.



12
13
14
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgia_event.rb', line 12

def memory_id
  @memory_id
end

#occurred_atObject (readonly)

Returns the value of attribute occurred_at.



12
13
14
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgia_event.rb', line 12

def occurred_at
  @occurred_at
end

#triggerObject (readonly)

Returns the value of attribute trigger.



12
13
14
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgia_event.rb', line 12

def trigger
  @trigger
end

Instance Method Details

#nostalgia_labelObject



23
24
25
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgia_event.rb', line 23

def nostalgia_label
  Constants.label_for(Constants::NOSTALGIA_LABELS, @intensity)
end

#to_hObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgia_event.rb', line 27

def to_h
  {
    id:              id,
    memory_id:       memory_id,
    trigger:         trigger,
    intensity:       @intensity,
    nostalgia_label: nostalgia_label,
    effect_on_mood:  @effect_on_mood,
    occurred_at:     occurred_at
  }
end