Class: Legion::Extensions::Agentic::Social::PerspectiveShifting::Helpers::PerspectiveView

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/social/perspective_shifting/helpers/perspective_view.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#concernsObject (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

#confidenceObject (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_atObject (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

#idObject (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

#opportunitiesObject (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_idObject (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_idObject (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

#valenceObject (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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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_hObject



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