Class: Legion::Extensions::Agentic::Attention::Spotlight::Helpers::Spotlight
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Attention::Spotlight::Helpers::Spotlight
show all
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/attention/spotlight/helpers/spotlight.rb
Constant Summary
Constants included
from Constants
Constants::CAPTURE_THRESHOLD, Constants::DEFAULT_BREADTH, Constants::DEFAULT_INTENSITY, Constants::INTENSITY_GAIN, Constants::INTENSITY_LABELS, Constants::INTENSITY_LOSS, Constants::MAX_PERIPHERAL, Constants::MAX_TARGETS, Constants::MODE_LABELS, Constants::PERIPHERAL_DETECTION_THRESHOLD, Constants::ZOOM_LEVELS, Constants::ZOOM_RANGES, Constants::ZOOM_STEP
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Spotlight.
Instance Attribute Details
#breadth ⇒ Object
Returns the value of attribute breadth.
12
13
14
|
# File 'lib/legion/extensions/agentic/attention/spotlight/helpers/spotlight.rb', line 12
def breadth
@breadth
end
|
#center_target_id ⇒ Object
Returns the value of attribute center_target_id.
12
13
14
|
# File 'lib/legion/extensions/agentic/attention/spotlight/helpers/spotlight.rb', line 12
def center_target_id
@center_target_id
end
|
#intensity ⇒ Object
Returns the value of attribute intensity.
12
13
14
|
# File 'lib/legion/extensions/agentic/attention/spotlight/helpers/spotlight.rb', line 12
def intensity
@intensity
end
|
#mode ⇒ Object
Returns the value of attribute mode.
12
13
14
|
# File 'lib/legion/extensions/agentic/attention/spotlight/helpers/spotlight.rb', line 12
def mode
@mode
end
|
Instance Method Details
#broaden! ⇒ Object
27
28
29
30
31
|
# File 'lib/legion/extensions/agentic/attention/spotlight/helpers/spotlight.rb', line 27
def broaden!
@breadth = (@breadth + Constants::ZOOM_STEP).clamp(0.0, 1.0).round(10)
@intensity = (@intensity - Constants::INTENSITY_LOSS).clamp(0.0, 1.0).round(10)
@mode = :scanning if @mode == :focused
end
|
#capture!(target_id) ⇒ Object
39
40
41
42
43
|
# File 'lib/legion/extensions/agentic/attention/spotlight/helpers/spotlight.rb', line 39
def capture!(target_id)
@center_target_id = target_id
@mode = :captured
@intensity = 1.0
end
|
#focus_on!(target_id) ⇒ Object
21
22
23
24
25
|
# File 'lib/legion/extensions/agentic/attention/spotlight/helpers/spotlight.rb', line 21
def focus_on!(target_id)
@center_target_id = target_id
@mode = :focused
@intensity = (@intensity + Constants::INTENSITY_GAIN).clamp(0.0, 1.0).round(10)
end
|
#intensity_label ⇒ Object
57
58
59
60
|
# File 'lib/legion/extensions/agentic/attention/spotlight/helpers/spotlight.rb', line 57
def intensity_label
entry = Constants::INTENSITY_LABELS.find { |il| il[:range].cover?(@intensity) }
entry&.fetch(:label, :moderate) || :moderate
end
|
#narrow! ⇒ Object
33
34
35
36
37
|
# File 'lib/legion/extensions/agentic/attention/spotlight/helpers/spotlight.rb', line 33
def narrow!
@breadth = (@breadth - Constants::ZOOM_STEP).clamp(0.0, 1.0).round(10)
@intensity = (@intensity + Constants::INTENSITY_GAIN).clamp(0.0, 1.0).round(10)
@mode = :focused if @center_target_id && @mode == :scanning
end
|
#to_h ⇒ Object
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/legion/extensions/agentic/attention/spotlight/helpers/spotlight.rb', line 62
def to_h
{
center_target_id: @center_target_id,
intensity: @intensity.round(10),
breadth: @breadth.round(10),
mode: @mode,
zoom_level: zoom_level,
intensity_label: intensity_label
}
end
|
#zoom_level ⇒ Object
52
53
54
55
|
# File 'lib/legion/extensions/agentic/attention/spotlight/helpers/spotlight.rb', line 52
def zoom_level
entry = Constants::ZOOM_RANGES.find { |z| z[:range].cover?(@breadth) }
entry&.fetch(:level, :moderate) || :moderate
end
|