Class: Legion::Extensions::Agentic::Executive::Compass::Helpers::Bearing
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Executive::Compass::Helpers::Bearing
- Defined in:
- lib/legion/extensions/agentic/executive/compass/helpers/bearing.rb
Instance Attribute Summary collapse
-
#confidence ⇒ Object
Returns the value of attribute confidence.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#taken_at ⇒ Object
readonly
Returns the value of attribute taken_at.
-
#value_axis ⇒ Object
readonly
Returns the value of attribute value_axis.
Instance Method Summary collapse
- #accuracy_label ⇒ Object
- #cardinal? ⇒ Boolean
-
#initialize(direction:, context:, confidence: nil) ⇒ Bearing
constructor
A new instance of Bearing.
- #lost? ⇒ Boolean
- #reliable? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(direction:, context:, confidence: nil) ⇒ Bearing
Returns a new instance of Bearing.
14 15 16 17 18 19 20 21 22 |
# File 'lib/legion/extensions/agentic/executive/compass/helpers/bearing.rb', line 14 def initialize(direction:, context:, confidence: nil) validate_direction!(direction) @id = SecureRandom.uuid @direction = direction.to_sym @value_axis = resolve_axis(direction.to_sym) @context = context.to_s @confidence = (confidence || 0.7).to_f.clamp(0.0, 1.0).round(10) @taken_at = Time.now.utc end |
Instance Attribute Details
#confidence ⇒ Object
Returns the value of attribute confidence.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/compass/helpers/bearing.rb', line 12 def confidence @confidence end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
10 11 12 |
# File 'lib/legion/extensions/agentic/executive/compass/helpers/bearing.rb', line 10 def context @context end |
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
10 11 12 |
# File 'lib/legion/extensions/agentic/executive/compass/helpers/bearing.rb', line 10 def direction @direction end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/legion/extensions/agentic/executive/compass/helpers/bearing.rb', line 10 def id @id end |
#taken_at ⇒ Object (readonly)
Returns the value of attribute taken_at.
10 11 12 |
# File 'lib/legion/extensions/agentic/executive/compass/helpers/bearing.rb', line 10 def taken_at @taken_at end |
#value_axis ⇒ Object (readonly)
Returns the value of attribute value_axis.
10 11 12 |
# File 'lib/legion/extensions/agentic/executive/compass/helpers/bearing.rb', line 10 def value_axis @value_axis end |
Instance Method Details
#accuracy_label ⇒ Object
36 37 38 |
# File 'lib/legion/extensions/agentic/executive/compass/helpers/bearing.rb', line 36 def accuracy_label Constants.label_for(Constants::ACCURACY_LABELS, @confidence) end |
#cardinal? ⇒ Boolean
32 33 34 |
# File 'lib/legion/extensions/agentic/executive/compass/helpers/bearing.rb', line 32 def cardinal? Constants::CARDINAL_DIRECTIONS.key?(@direction) end |
#lost? ⇒ Boolean
28 29 30 |
# File 'lib/legion/extensions/agentic/executive/compass/helpers/bearing.rb', line 28 def lost? @confidence < 0.2 end |
#reliable? ⇒ Boolean
24 25 26 |
# File 'lib/legion/extensions/agentic/executive/compass/helpers/bearing.rb', line 24 def reliable? @confidence >= 0.6 end |
#to_h ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/legion/extensions/agentic/executive/compass/helpers/bearing.rb', line 40 def to_h { id: @id, direction: @direction, value_axis: @value_axis, context: @context, confidence: @confidence, accuracy_label: accuracy_label, cardinal: cardinal?, reliable: reliable?, lost: lost?, taken_at: @taken_at } end |