Class: Legion::Gaia::NotificationGate::BehavioralEvaluator
- Inherits:
-
Object
- Object
- Legion::Gaia::NotificationGate::BehavioralEvaluator
- Defined in:
- lib/legion/gaia/notification_gate/behavioral_evaluator.rb
Constant Summary collapse
- PRIORITY_BASE_THRESHOLD =
{ critical: 0.0, urgent: 0.0, normal: 0.3, low: 0.5, ambient: 0.7 }.freeze
- THRESHOLD_MODIFIER =
0.3
Instance Method Summary collapse
-
#initialize ⇒ BehavioralEvaluator
constructor
A new instance of BehavioralEvaluator.
- #notification_score ⇒ Object
- #should_deliver?(priority: :normal) ⇒ Boolean
- #update_arousal(value) ⇒ Object
- #update_idle_seconds(seconds) ⇒ Object
Constructor Details
#initialize ⇒ BehavioralEvaluator
Returns a new instance of BehavioralEvaluator.
10 11 12 13 |
# File 'lib/legion/gaia/notification_gate/behavioral_evaluator.rb', line 10 def initialize @arousal = nil @idle_seconds = nil end |
Instance Method Details
#notification_score ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/legion/gaia/notification_gate/behavioral_evaluator.rb', line 23 def notification_score signals = [] signals << arousal_signal if @arousal signals << idle_signal if @idle_seconds return 1.0 if signals.empty? signals.sum / signals.size end |
#should_deliver?(priority: :normal) ⇒ Boolean
33 34 35 36 37 |
# File 'lib/legion/gaia/notification_gate/behavioral_evaluator.rb', line 33 def should_deliver?(priority: :normal) base = PRIORITY_BASE_THRESHOLD[priority] || PRIORITY_BASE_THRESHOLD[:normal] effective_threshold = base + ((1.0 - notification_score) * THRESHOLD_MODIFIER) priority_value(priority) >= effective_threshold end |
#update_arousal(value) ⇒ Object
15 16 17 |
# File 'lib/legion/gaia/notification_gate/behavioral_evaluator.rb', line 15 def update_arousal(value) @arousal = value.to_f.clamp(0.0, 1.0) end |
#update_idle_seconds(seconds) ⇒ Object
19 20 21 |
# File 'lib/legion/gaia/notification_gate/behavioral_evaluator.rb', line 19 def update_idle_seconds(seconds) @idle_seconds = seconds.to_f end |