Class: Legion::Extensions::Agentic::Inference::Gravity::Helpers::OrbitingThought
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Inference::Gravity::Helpers::OrbitingThought
- Defined in:
- lib/legion/extensions/agentic/inference/gravity/helpers/orbiting_thought.rb
Instance Attribute Summary collapse
-
#attractor_id ⇒ Object
readonly
Returns the value of attribute attractor_id.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#orbital_distance ⇒ Object
readonly
Returns the value of attribute orbital_distance.
-
#velocity ⇒ Object
readonly
Returns the value of attribute velocity.
Instance Method Summary collapse
- #approach!(delta) ⇒ Object
- #captured? ⇒ Boolean
- #escape!(delta) ⇒ Object
- #escaped? ⇒ Boolean
-
#initialize(content:, attractor_id:, orbital_distance: 1.0, velocity: 0.0) ⇒ OrbitingThought
constructor
A new instance of OrbitingThought.
- #orbit_label ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(content:, attractor_id:, orbital_distance: 1.0, velocity: 0.0) ⇒ OrbitingThought
Returns a new instance of OrbitingThought.
14 15 16 17 18 19 20 21 |
# File 'lib/legion/extensions/agentic/inference/gravity/helpers/orbiting_thought.rb', line 14 def initialize(content:, attractor_id:, orbital_distance: 1.0, velocity: 0.0) @id = SecureRandom.uuid @content = content @attractor_id = attractor_id @orbital_distance = orbital_distance.clamp(0.0, Float::INFINITY).round(10) @velocity = velocity.to_f.round(10) @created_at = Time.now.utc end |
Instance Attribute Details
#attractor_id ⇒ Object (readonly)
Returns the value of attribute attractor_id.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/gravity/helpers/orbiting_thought.rb', line 12 def attractor_id @attractor_id end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/gravity/helpers/orbiting_thought.rb', line 12 def content @content end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/gravity/helpers/orbiting_thought.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/inference/gravity/helpers/orbiting_thought.rb', line 12 def id @id end |
#orbital_distance ⇒ Object (readonly)
Returns the value of attribute orbital_distance.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/gravity/helpers/orbiting_thought.rb', line 12 def orbital_distance @orbital_distance end |
#velocity ⇒ Object (readonly)
Returns the value of attribute velocity.
12 13 14 |
# File 'lib/legion/extensions/agentic/inference/gravity/helpers/orbiting_thought.rb', line 12 def velocity @velocity end |
Instance Method Details
#approach!(delta) ⇒ Object
23 24 25 26 |
# File 'lib/legion/extensions/agentic/inference/gravity/helpers/orbiting_thought.rb', line 23 def approach!(delta) @orbital_distance = [(@orbital_distance - delta.abs).round(10), 0.0].max self end |
#captured? ⇒ Boolean
33 34 35 |
# File 'lib/legion/extensions/agentic/inference/gravity/helpers/orbiting_thought.rb', line 33 def captured? @orbital_distance < Constants::CAPTURE_RADIUS end |
#escape!(delta) ⇒ Object
28 29 30 31 |
# File 'lib/legion/extensions/agentic/inference/gravity/helpers/orbiting_thought.rb', line 28 def escape!(delta) @orbital_distance = (@orbital_distance + delta.abs).round(10) self end |
#escaped? ⇒ Boolean
37 38 39 |
# File 'lib/legion/extensions/agentic/inference/gravity/helpers/orbiting_thought.rb', line 37 def escaped? @orbital_distance > Constants::ESCAPE_RADIUS end |
#orbit_label ⇒ Object
41 42 43 |
# File 'lib/legion/extensions/agentic/inference/gravity/helpers/orbiting_thought.rb', line 41 def orbit_label Constants.label_for(Constants::ORBIT_LABELS, @orbital_distance) end |
#to_h ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/legion/extensions/agentic/inference/gravity/helpers/orbiting_thought.rb', line 45 def to_h { id: @id, content: @content, attractor_id: @attractor_id, orbital_distance: @orbital_distance, velocity: @velocity, captured: captured?, escaped: escaped?, orbit_label: orbit_label, created_at: @created_at } end |