Class: Legion::Extensions::Agentic::Self::NarrativeIdentity::Helpers::Theme
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Self::NarrativeIdentity::Helpers::Theme
- Defined in:
- lib/legion/extensions/agentic/self/narrative_identity/helpers/theme.rb
Instance Attribute Summary collapse
-
#episode_ids ⇒ Object
readonly
Returns the value of attribute episode_ids.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#strength ⇒ Object
Returns the value of attribute strength.
-
#theme_type ⇒ Object
readonly
Returns the value of attribute theme_type.
Instance Method Summary collapse
- #decay! ⇒ Object
-
#initialize(name:, theme_type:, strength: 0.0, episode_ids: nil, id: nil) ⇒ Theme
constructor
A new instance of Theme.
- #prominent? ⇒ Boolean
- #reinforce!(amount) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(name:, theme_type:, strength: 0.0, episode_ids: nil, id: nil) ⇒ Theme
Returns a new instance of Theme.
15 16 17 18 19 20 21 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/theme.rb', line 15 def initialize(name:, theme_type:, strength: 0.0, episode_ids: nil, id: nil) @id = id || SecureRandom.uuid @name = name @theme_type = theme_type @strength = strength.clamp(0.0, 1.0) @episode_ids = episode_ids || [] end |
Instance Attribute Details
#episode_ids ⇒ Object (readonly)
Returns the value of attribute episode_ids.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/theme.rb', line 12 def episode_ids @episode_ids end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/theme.rb', line 12 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/theme.rb', line 12 def name @name end |
#strength ⇒ Object
Returns the value of attribute strength.
13 14 15 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/theme.rb', line 13 def strength @strength end |
#theme_type ⇒ Object (readonly)
Returns the value of attribute theme_type.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/theme.rb', line 12 def theme_type @theme_type end |
Instance Method Details
#decay! ⇒ Object
27 28 29 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/theme.rb', line 27 def decay! @strength = (@strength - Constants::COHERENCE_DECAY).clamp(0.0, 1.0).round(10) end |
#prominent? ⇒ Boolean
31 32 33 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/theme.rb', line 31 def prominent? @strength >= 0.6 end |
#reinforce!(amount) ⇒ Object
23 24 25 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/theme.rb', line 23 def reinforce!(amount) @strength = (@strength + amount).clamp(0.0, 1.0).round(10) end |
#to_h ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/theme.rb', line 35 def to_h { id: @id, name: @name, theme_type: @theme_type, strength: @strength, episode_ids: @episode_ids.dup } end |