Class: Legion::Extensions::Agentic::Self::Architecture::Helpers::Connection
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Self::Architecture::Helpers::Connection
- Defined in:
- lib/legion/extensions/agentic/self/architecture/helpers/connection.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#connection_type ⇒ Object
readonly
Returns the value of attribute connection_type.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#source_id ⇒ Object
readonly
Returns the value of attribute source_id.
-
#target_id ⇒ Object
readonly
Returns the value of attribute target_id.
-
#weight ⇒ Object
Returns the value of attribute weight.
Instance Method Summary collapse
-
#initialize(source_id:, target_id:, connection_type: :informational, weight: 0.5) ⇒ Connection
constructor
A new instance of Connection.
- #strengthen!(amount = 0.05) ⇒ Object
- #to_h ⇒ Object
- #toggle! ⇒ Object
- #weaken!(amount = 0.05) ⇒ Object
Constructor Details
#initialize(source_id:, target_id:, connection_type: :informational, weight: 0.5) ⇒ Connection
Returns a new instance of Connection.
15 16 17 18 19 20 21 22 23 |
# File 'lib/legion/extensions/agentic/self/architecture/helpers/connection.rb', line 15 def initialize(source_id:, target_id:, connection_type: :informational, weight: 0.5) @id = SecureRandom.uuid @source_id = source_id @target_id = target_id @connection_type = connection_type.to_sym @weight = weight.clamp(0.0, 1.0) @active = true @created_at = Time.now.utc end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
13 14 15 |
# File 'lib/legion/extensions/agentic/self/architecture/helpers/connection.rb', line 13 def active @active end |
#connection_type ⇒ Object (readonly)
Returns the value of attribute connection_type.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/architecture/helpers/connection.rb', line 12 def connection_type @connection_type end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/architecture/helpers/connection.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/self/architecture/helpers/connection.rb', line 12 def id @id end |
#source_id ⇒ Object (readonly)
Returns the value of attribute source_id.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/architecture/helpers/connection.rb', line 12 def source_id @source_id end |
#target_id ⇒ Object (readonly)
Returns the value of attribute target_id.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/architecture/helpers/connection.rb', line 12 def target_id @target_id end |
#weight ⇒ Object
Returns the value of attribute weight.
13 14 15 |
# File 'lib/legion/extensions/agentic/self/architecture/helpers/connection.rb', line 13 def weight @weight end |
Instance Method Details
#strengthen!(amount = 0.05) ⇒ Object
25 26 27 28 |
# File 'lib/legion/extensions/agentic/self/architecture/helpers/connection.rb', line 25 def strengthen!(amount = 0.05) @weight = (@weight + amount).clamp(0.0, 1.0) self end |
#to_h ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/legion/extensions/agentic/self/architecture/helpers/connection.rb', line 40 def to_h { id: @id, source_id: @source_id, target_id: @target_id, connection_type: @connection_type, weight: @weight, active: @active, created_at: @created_at } end |
#toggle! ⇒ Object
35 36 37 38 |
# File 'lib/legion/extensions/agentic/self/architecture/helpers/connection.rb', line 35 def toggle! @active = !@active self end |
#weaken!(amount = 0.05) ⇒ Object
30 31 32 33 |
# File 'lib/legion/extensions/agentic/self/architecture/helpers/connection.rb', line 30 def weaken!(amount = 0.05) @weight = (@weight - amount).clamp(0.0, 1.0) self end |