Class: Legion::Extensions::Agentic::Social::PerspectiveShifting::Helpers::PerspectiveView
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Social::PerspectiveShifting::Helpers::PerspectiveView
- Defined in:
- lib/legion/extensions/agentic/social/perspective_shifting/helpers/perspective_view.rb
Instance Attribute Summary collapse
-
#concerns ⇒ Object
readonly
Returns the value of attribute concerns.
-
#confidence ⇒ Object
readonly
Returns the value of attribute confidence.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#opportunities ⇒ Object
readonly
Returns the value of attribute opportunities.
-
#perspective_id ⇒ Object
readonly
Returns the value of attribute perspective_id.
-
#situation_id ⇒ Object
readonly
Returns the value of attribute situation_id.
-
#valence ⇒ Object
readonly
Returns the value of attribute valence.
Instance Method Summary collapse
-
#initialize(situation_id:, perspective_id:, valence: 0.0, concerns: [], opportunities: [], confidence: 0.5) ⇒ PerspectiveView
constructor
A new instance of PerspectiveView.
- #negative? ⇒ Boolean
- #neutral? ⇒ Boolean
- #positive? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(situation_id:, perspective_id:, valence: 0.0, concerns: [], opportunities: [], confidence: 0.5) ⇒ PerspectiveView
Returns a new instance of PerspectiveView.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/social/perspective_shifting/helpers/perspective_view.rb', line 15 def initialize(situation_id:, perspective_id:, valence: 0.0, concerns: [], opportunities: [], confidence: 0.5) @id = SecureRandom.uuid @situation_id = situation_id @perspective_id = perspective_id @valence = valence.clamp(-1.0, 1.0).round(10) @concerns = Array(concerns) @opportunities = Array(opportunities) @confidence = confidence.clamp(0.0, 1.0).round(10) @created_at = Time.now.utc end |
Instance Attribute Details
#concerns ⇒ Object (readonly)
Returns the value of attribute concerns.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/perspective_shifting/helpers/perspective_view.rb', line 12 def concerns @concerns end |
#confidence ⇒ Object (readonly)
Returns the value of attribute confidence.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/perspective_shifting/helpers/perspective_view.rb', line 12 def confidence @confidence end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/perspective_shifting/helpers/perspective_view.rb', line 12 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/perspective_shifting/helpers/perspective_view.rb', line 12 def id @id end |
#opportunities ⇒ Object (readonly)
Returns the value of attribute opportunities.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/perspective_shifting/helpers/perspective_view.rb', line 12 def opportunities @opportunities end |
#perspective_id ⇒ Object (readonly)
Returns the value of attribute perspective_id.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/perspective_shifting/helpers/perspective_view.rb', line 12 def perspective_id @perspective_id end |
#situation_id ⇒ Object (readonly)
Returns the value of attribute situation_id.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/perspective_shifting/helpers/perspective_view.rb', line 12 def situation_id @situation_id end |
#valence ⇒ Object (readonly)
Returns the value of attribute valence.
12 13 14 |
# File 'lib/legion/extensions/agentic/social/perspective_shifting/helpers/perspective_view.rb', line 12 def valence @valence end |
Instance Method Details
#negative? ⇒ Boolean
31 32 33 |
# File 'lib/legion/extensions/agentic/social/perspective_shifting/helpers/perspective_view.rb', line 31 def negative? @valence < -0.1 end |
#neutral? ⇒ Boolean
35 36 37 |
# File 'lib/legion/extensions/agentic/social/perspective_shifting/helpers/perspective_view.rb', line 35 def neutral? !positive? && !negative? end |
#positive? ⇒ Boolean
27 28 29 |
# File 'lib/legion/extensions/agentic/social/perspective_shifting/helpers/perspective_view.rb', line 27 def positive? @valence > 0.1 end |
#to_h ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/legion/extensions/agentic/social/perspective_shifting/helpers/perspective_view.rb', line 39 def to_h { id: @id, situation_id: @situation_id, perspective_id: @perspective_id, valence: @valence, concerns: @concerns, opportunities: @opportunities, confidence: @confidence, created_at: @created_at } end |