Class: Legion::Extensions::Agentic::Self::NarrativeIdentity::Helpers::Episode
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Self::NarrativeIdentity::Helpers::Episode
- Defined in:
- lib/legion/extensions/agentic/self/narrative_identity/helpers/episode.rb
Instance Attribute Summary collapse
-
#chapter_id ⇒ Object
Returns the value of attribute chapter_id.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#emotional_valence ⇒ Object
readonly
Returns the value of attribute emotional_valence.
-
#episode_type ⇒ Object
readonly
Returns the value of attribute episode_type.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#significance ⇒ Object
readonly
Returns the value of attribute significance.
-
#themes ⇒ Object
readonly
Returns the value of attribute themes.
Instance Method Summary collapse
- #defining? ⇒ Boolean
-
#initialize(content:, episode_type:, emotional_valence:, significance:, domain:) ⇒ Episode
constructor
A new instance of Episode.
- #negative? ⇒ Boolean
- #positive? ⇒ Boolean
- #significance_label ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(content:, episode_type:, emotional_valence:, significance:, domain:) ⇒ Episode
Returns a new instance of Episode.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/episode.rb', line 16 def initialize(content:, episode_type:, emotional_valence:, significance:, domain:, **) @id = SecureRandom.uuid @content = content @episode_type = episode_type @emotional_valence = emotional_valence.clamp(-1.0, 1.0) @significance = significance.clamp(0.0, 1.0) @domain = domain @chapter_id = nil @themes = [] @created_at = Time.now.utc end |
Instance Attribute Details
#chapter_id ⇒ Object
Returns the value of attribute chapter_id.
14 15 16 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/episode.rb', line 14 def chapter_id @chapter_id end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/episode.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/self/narrative_identity/helpers/episode.rb', line 12 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/episode.rb', line 12 def domain @domain end |
#emotional_valence ⇒ Object (readonly)
Returns the value of attribute emotional_valence.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/episode.rb', line 12 def emotional_valence @emotional_valence end |
#episode_type ⇒ Object (readonly)
Returns the value of attribute episode_type.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/episode.rb', line 12 def episode_type @episode_type end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/episode.rb', line 12 def id @id end |
#significance ⇒ Object (readonly)
Returns the value of attribute significance.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/episode.rb', line 12 def significance @significance end |
#themes ⇒ Object (readonly)
Returns the value of attribute themes.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/episode.rb', line 12 def themes @themes end |
Instance Method Details
#defining? ⇒ Boolean
36 37 38 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/episode.rb', line 36 def defining? @significance >= 0.8 end |
#negative? ⇒ Boolean
32 33 34 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/episode.rb', line 32 def negative? @emotional_valence.negative? end |
#positive? ⇒ Boolean
28 29 30 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/episode.rb', line 28 def positive? @emotional_valence.positive? end |
#significance_label ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/episode.rb', line 40 def significance_label Constants::SIGNIFICANCE_LABELS.each do |entry| range, label = entry.first return label if range.cover?(@significance) end :trivial end |
#to_h ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/episode.rb', line 48 def to_h { id: @id, content: @content, episode_type: @episode_type, emotional_valence: @emotional_valence, significance: @significance, domain: @domain, chapter_id: @chapter_id, themes: @themes.dup, created_at: @created_at } end |