Class: Legion::Extensions::Agentic::Integration::Zeitgeist::Helpers::CognitiveSignal

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/integration/zeitgeist/helpers/cognitive_signal.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_subsystem:, domain:, intensity: Constants::DEFAULT_INTENSITY, valence: 0.0, timestamp: nil) ⇒ CognitiveSignal

Returns a new instance of CognitiveSignal.



12
13
14
15
16
17
18
19
20
# File 'lib/legion/extensions/agentic/integration/zeitgeist/helpers/cognitive_signal.rb', line 12

def initialize(source_subsystem:, domain:, intensity: Constants::DEFAULT_INTENSITY,
               valence: 0.0, timestamp: nil)
  @id               = SecureRandom.uuid
  @source_subsystem = source_subsystem.to_sym
  @domain           = domain.to_sym
  @intensity        = intensity.to_f.clamp(0.0, 1.0)
  @valence          = valence.to_f.clamp(-1.0, 1.0)
  @timestamp        = timestamp || Time.now.utc
end

Instance Attribute Details

#domainObject (readonly)

Returns the value of attribute domain.



10
11
12
# File 'lib/legion/extensions/agentic/integration/zeitgeist/helpers/cognitive_signal.rb', line 10

def domain
  @domain
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/legion/extensions/agentic/integration/zeitgeist/helpers/cognitive_signal.rb', line 10

def id
  @id
end

#intensityObject (readonly)

Returns the value of attribute intensity.



10
11
12
# File 'lib/legion/extensions/agentic/integration/zeitgeist/helpers/cognitive_signal.rb', line 10

def intensity
  @intensity
end

#source_subsystemObject (readonly)

Returns the value of attribute source_subsystem.



10
11
12
# File 'lib/legion/extensions/agentic/integration/zeitgeist/helpers/cognitive_signal.rb', line 10

def source_subsystem
  @source_subsystem
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



10
11
12
# File 'lib/legion/extensions/agentic/integration/zeitgeist/helpers/cognitive_signal.rb', line 10

def timestamp
  @timestamp
end

#valenceObject (readonly)

Returns the value of attribute valence.



10
11
12
# File 'lib/legion/extensions/agentic/integration/zeitgeist/helpers/cognitive_signal.rb', line 10

def valence
  @valence
end

Instance Method Details

#to_hObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/legion/extensions/agentic/integration/zeitgeist/helpers/cognitive_signal.rb', line 22

def to_h
  {
    id:               @id,
    source_subsystem: @source_subsystem,
    domain:           @domain,
    intensity:        @intensity.round(10),
    valence:          @valence.round(10),
    timestamp:        @timestamp.iso8601
  }
end