Class: Legion::Extensions::Agentic::Executive::Triage::Helpers::Demand
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Executive::Triage::Helpers::Demand
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/executive/triage/helpers/demand.rb
Constant Summary
Constants included from Constants
Constants::CAPACITY_DEFAULT, Constants::CAPACITY_DRAIN, Constants::CAPACITY_LABELS, Constants::CAPACITY_RESTORE, Constants::MAX_DEMANDS, Constants::MAX_QUEUE_SIZE, Constants::OVERLOAD_THRESHOLD, Constants::QUEUE_LABELS, Constants::SEVERITY_LEVELS, Constants::SEVERITY_WEIGHTS, Constants::TRIAGE_LABELS, Constants::URGENCY_LEVELS, Constants::URGENCY_WEIGHTS
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#triage_score ⇒ Object
readonly
Returns the value of attribute triage_score.
-
#triaged_at ⇒ Object
readonly
Returns the value of attribute triaged_at.
-
#urgency ⇒ Object
readonly
Returns the value of attribute urgency.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #complete! ⇒ Object
- #defer! ⇒ Object
- #drop! ⇒ Object
-
#initialize(description:, domain: :general, severity: :moderate, urgency: :soon) ⇒ Demand
constructor
A new instance of Demand.
- #process! ⇒ Object
- #red? ⇒ Boolean
- #to_h ⇒ Object
- #triage! ⇒ Object
- #triage_label ⇒ Object
Methods included from Constants
Constructor Details
#initialize(description:, domain: :general, severity: :moderate, urgency: :soon) ⇒ Demand
Returns a new instance of Demand.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 17 def initialize(description:, domain: :general, severity: :moderate, urgency: :soon) @id = SecureRandom.uuid @description = description @domain = domain.to_sym @severity = validate_level(severity, SEVERITY_LEVELS, :moderate) @urgency = validate_level(urgency, URGENCY_LEVELS, :soon) @triage_score = compute_triage_score @status = :pending @created_at = Time.now.utc @triaged_at = nil end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14 def created_at @created_at end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14 def description @description end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14 def id @id end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14 def severity @severity end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14 def status @status end |
#triage_score ⇒ Object (readonly)
Returns the value of attribute triage_score.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14 def triage_score @triage_score end |
#triaged_at ⇒ Object (readonly)
Returns the value of attribute triaged_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14 def triaged_at @triaged_at end |
#urgency ⇒ Object (readonly)
Returns the value of attribute urgency.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 14 def urgency @urgency end |
Instance Method Details
#active? ⇒ Boolean
55 56 57 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 55 def active? %i[pending triaged processing].include?(@status) end |
#complete! ⇒ Object
45 46 47 48 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 45 def complete! @status = :completed self end |
#defer! ⇒ Object
35 36 37 38 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 35 def defer! @status = :deferred self end |
#drop! ⇒ Object
50 51 52 53 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 50 def drop! @status = :dropped self end |
#process! ⇒ Object
40 41 42 43 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 40 def process! @status = :processing self end |
#red? ⇒ Boolean
63 64 65 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 63 def red? @triage_score >= 0.8 end |
#to_h ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 67 def to_h { id: @id, description: @description, domain: @domain, severity: @severity, urgency: @urgency, triage_score: @triage_score, triage_label: triage_label, status: @status, red: red?, created_at: @created_at, triaged_at: @triaged_at } end |
#triage! ⇒ Object
29 30 31 32 33 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 29 def triage! @status = :triaged @triaged_at = Time.now.utc self end |
#triage_label ⇒ Object
59 60 61 |
# File 'lib/legion/extensions/agentic/executive/triage/helpers/demand.rb', line 59 def triage_label Constants.label_for(TRIAGE_LABELS, @triage_score) end |