Class: Legion::Extensions::Agentic::Defense::Phantom::Helpers::PhantomSignal

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/defense/phantom/helpers/phantom_signal.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(phantom_limb_id:, stimulus:, trigger_type:, intensity_at_trigger:) ⇒ PhantomSignal

Returns a new instance of PhantomSignal.



15
16
17
18
19
20
21
22
# File 'lib/legion/extensions/agentic/defense/phantom/helpers/phantom_signal.rb', line 15

def initialize(phantom_limb_id:, stimulus:, trigger_type:, intensity_at_trigger:)
  @id                  = SecureRandom.uuid
  @phantom_limb_id     = phantom_limb_id
  @stimulus            = stimulus
  @trigger_type        = trigger_type
  @intensity_at_trigger = intensity_at_trigger.clamp(0.0, 1.0)
  @timestamp = Time.now.utc
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/defense/phantom/helpers/phantom_signal.rb', line 12

def id
  @id
end

#intensity_at_triggerObject (readonly)

Returns the value of attribute intensity_at_trigger.



12
13
14
# File 'lib/legion/extensions/agentic/defense/phantom/helpers/phantom_signal.rb', line 12

def intensity_at_trigger
  @intensity_at_trigger
end

#phantom_limb_idObject (readonly)

Returns the value of attribute phantom_limb_id.



12
13
14
# File 'lib/legion/extensions/agentic/defense/phantom/helpers/phantom_signal.rb', line 12

def phantom_limb_id
  @phantom_limb_id
end

#stimulusObject (readonly)

Returns the value of attribute stimulus.



12
13
14
# File 'lib/legion/extensions/agentic/defense/phantom/helpers/phantom_signal.rb', line 12

def stimulus
  @stimulus
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



12
13
14
# File 'lib/legion/extensions/agentic/defense/phantom/helpers/phantom_signal.rb', line 12

def timestamp
  @timestamp
end

#trigger_typeObject (readonly)

Returns the value of attribute trigger_type.



12
13
14
# File 'lib/legion/extensions/agentic/defense/phantom/helpers/phantom_signal.rb', line 12

def trigger_type
  @trigger_type
end

Instance Method Details

#to_hObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/legion/extensions/agentic/defense/phantom/helpers/phantom_signal.rb', line 24

def to_h
  {
    id:                   @id,
    phantom_limb_id:      @phantom_limb_id,
    stimulus:             @stimulus,
    trigger_type:         @trigger_type,
    intensity_at_trigger: @intensity_at_trigger.round(10),
    timestamp:            @timestamp
  }
end