Class: Legion::Extensions::Agentic::Self::NarrativeIdentity::Helpers::Chapter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, label:, episode_ids: nil, start_time: nil, end_time: nil, id: nil) ⇒ Chapter

Returns a new instance of Chapter.



15
16
17
18
19
20
21
22
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/chapter.rb', line 15

def initialize(title:, label:, episode_ids: nil, start_time: nil, end_time: nil, id: nil)
  @id          = id || SecureRandom.uuid
  @title       = title
  @label       = label
  @episode_ids = episode_ids || []
  @start_time  = start_time || Time.now.utc
  @end_time    = end_time
end

Instance Attribute Details

#end_timeObject

Returns the value of attribute end_time.



13
14
15
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/chapter.rb', line 13

def end_time
  @end_time
end

#episode_idsObject (readonly)

Returns the value of attribute episode_ids.



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

def episode_ids
  @episode_ids
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#labelObject (readonly)

Returns the value of attribute label.



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

def label
  @label
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



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

def start_time
  @start_time
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#current?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/chapter.rb', line 24

def current?
  @end_time.nil?
end

#episode_countObject



28
29
30
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/chapter.rb', line 28

def episode_count
  @episode_ids.size
end

#to_hObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/legion/extensions/agentic/self/narrative_identity/helpers/chapter.rb', line 32

def to_h
  {
    id:          @id,
    title:       @title,
    label:       @label,
    episode_ids: @episode_ids.dup,
    start_time:  @start_time,
    end_time:    @end_time
  }
end