Class: Legion::Extensions::Agentic::Self::NarrativeArc::Helpers::BeatEvent

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/self/narrative_arc/helpers/beat_event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:, intensity: 0.5, beat_type: :rising_action, domain: :general, emotional_charge: 0.0) ⇒ BeatEvent

Returns a new instance of BeatEvent.



15
16
17
18
19
20
21
22
23
24
# File 'lib/legion/extensions/agentic/self/narrative_arc/helpers/beat_event.rb', line 15

def initialize(content:, intensity: 0.5, beat_type: :rising_action,
               domain: :general, emotional_charge: 0.0)
  @beat_id        = SecureRandom.uuid
  @content        = content
  @intensity      = intensity.clamp(0.0, 1.0)
  @beat_type      = validate_beat_type(beat_type)
  @domain         = domain
  @emotional_charge = emotional_charge.clamp(-1.0, 1.0)
  @created_at = Time.now.utc
end

Instance Attribute Details

#beat_idObject (readonly)

Returns the value of attribute beat_id.



12
13
14
# File 'lib/legion/extensions/agentic/self/narrative_arc/helpers/beat_event.rb', line 12

def beat_id
  @beat_id
end

#beat_typeObject (readonly)

Returns the value of attribute beat_type.



12
13
14
# File 'lib/legion/extensions/agentic/self/narrative_arc/helpers/beat_event.rb', line 12

def beat_type
  @beat_type
end

#contentObject (readonly)

Returns the value of attribute content.



12
13
14
# File 'lib/legion/extensions/agentic/self/narrative_arc/helpers/beat_event.rb', line 12

def content
  @content
end

#created_atObject (readonly)

Returns the value of attribute created_at.



12
13
14
# File 'lib/legion/extensions/agentic/self/narrative_arc/helpers/beat_event.rb', line 12

def created_at
  @created_at
end

#domainObject (readonly)

Returns the value of attribute domain.



12
13
14
# File 'lib/legion/extensions/agentic/self/narrative_arc/helpers/beat_event.rb', line 12

def domain
  @domain
end

#emotional_chargeObject (readonly)

Returns the value of attribute emotional_charge.



12
13
14
# File 'lib/legion/extensions/agentic/self/narrative_arc/helpers/beat_event.rb', line 12

def emotional_charge
  @emotional_charge
end

#intensityObject (readonly)

Returns the value of attribute intensity.



12
13
14
# File 'lib/legion/extensions/agentic/self/narrative_arc/helpers/beat_event.rb', line 12

def intensity
  @intensity
end

Instance Method Details

#climactic?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/legion/extensions/agentic/self/narrative_arc/helpers/beat_event.rb', line 38

def climactic?
  @beat_type == :climax || @intensity >= Constants::CLIMAX_THRESHOLD
end

#resolving?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/legion/extensions/agentic/self/narrative_arc/helpers/beat_event.rb', line 42

def resolving?
  %i[falling_action resolution denouement].include?(@beat_type)
end

#to_hObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/legion/extensions/agentic/self/narrative_arc/helpers/beat_event.rb', line 26

def to_h
  {
    beat_id:          @beat_id,
    content:          @content,
    intensity:        @intensity,
    beat_type:        @beat_type,
    domain:           @domain,
    emotional_charge: @emotional_charge,
    created_at:       @created_at
  }
end