Class: Legion::Extensions::Agentic::Attention::Blink::Helpers::Stimulus
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Attention::Blink::Helpers::Stimulus
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/attention/blink/helpers/stimulus.rb
Constant Summary
Constants included from Constants
Constants::DEFAULT_BLINK_DURATION, Constants::LAG1_SPARING_THRESHOLD, Constants::MAX_BLINKS, Constants::MAX_BLINK_DURATION, Constants::MAX_STIMULI, Constants::MIN_BLINK_DURATION, Constants::PROCESSING_LABELS, Constants::RECOVERY_LABELS, Constants::RECOVERY_RATE, Constants::SALIENCE_THRESHOLD, Constants::STIMULUS_TYPES
Instance Attribute Summary collapse
-
#arrival_time ⇒ Object
readonly
Returns the value of attribute arrival_time.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#processed ⇒ Object
readonly
Returns the value of attribute processed.
-
#processing_quality ⇒ Object
readonly
Returns the value of attribute processing_quality.
-
#salience ⇒ Object
readonly
Returns the value of attribute salience.
-
#stimulus_type ⇒ Object
readonly
Returns the value of attribute stimulus_type.
Instance Method Summary collapse
-
#initialize(stimulus_type:, content:, salience: 0.5, arrival_time: nil) ⇒ Stimulus
constructor
A new instance of Stimulus.
- #missed? ⇒ Boolean
- #process!(quality:) ⇒ Object
- #processing_label ⇒ Object
- #salient? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(stimulus_type:, content:, salience: 0.5, arrival_time: nil) ⇒ Stimulus
Returns a new instance of Stimulus.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/legion/extensions/agentic/attention/blink/helpers/stimulus.rb', line 17 def initialize(stimulus_type:, content:, salience: 0.5, arrival_time: nil) @id = SecureRandom.uuid @stimulus_type = stimulus_type.to_sym @content = content @salience = salience.to_f.clamp(0.0, 1.0) @processed = false @processing_quality = 0.0 @arrival_time = arrival_time || Time.now.utc.to_f @created_at = Time.now.utc end |
Instance Attribute Details
#arrival_time ⇒ Object (readonly)
Returns the value of attribute arrival_time.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/blink/helpers/stimulus.rb', line 14 def arrival_time @arrival_time end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/blink/helpers/stimulus.rb', line 14 def content @content end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/blink/helpers/stimulus.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/blink/helpers/stimulus.rb', line 14 def id @id end |
#processed ⇒ Object (readonly)
Returns the value of attribute processed.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/blink/helpers/stimulus.rb', line 14 def processed @processed end |
#processing_quality ⇒ Object (readonly)
Returns the value of attribute processing_quality.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/blink/helpers/stimulus.rb', line 14 def processing_quality @processing_quality end |
#salience ⇒ Object (readonly)
Returns the value of attribute salience.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/blink/helpers/stimulus.rb', line 14 def salience @salience end |
#stimulus_type ⇒ Object (readonly)
Returns the value of attribute stimulus_type.
14 15 16 |
# File 'lib/legion/extensions/agentic/attention/blink/helpers/stimulus.rb', line 14 def stimulus_type @stimulus_type end |
Instance Method Details
#missed? ⇒ Boolean
43 44 45 |
# File 'lib/legion/extensions/agentic/attention/blink/helpers/stimulus.rb', line 43 def missed? @processed && @processing_quality < 0.2 end |
#process!(quality:) ⇒ Object
28 29 30 31 32 |
# File 'lib/legion/extensions/agentic/attention/blink/helpers/stimulus.rb', line 28 def process!(quality:) @processed = true @processing_quality = quality.to_f.clamp(0.0, 1.0) self end |
#processing_label ⇒ Object
38 39 40 41 |
# File 'lib/legion/extensions/agentic/attention/blink/helpers/stimulus.rb', line 38 def processing_label match = PROCESSING_LABELS.find { |range, _| range.cover?(@processing_quality) } match ? match.last : :blinked end |
#salient? ⇒ Boolean
34 35 36 |
# File 'lib/legion/extensions/agentic/attention/blink/helpers/stimulus.rb', line 34 def salient? @salience >= SALIENCE_THRESHOLD end |
#to_h ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/legion/extensions/agentic/attention/blink/helpers/stimulus.rb', line 47 def to_h { id: @id, stimulus_type: @stimulus_type, content: @content, salience: @salience, processed: @processed, processing_quality: @processing_quality, processing_label: processing_label, salient: salient?, missed: missed?, arrival_time: @arrival_time, created_at: @created_at } end |