Class: Flows::SharedContextPipeline::TrackList Private

Inherits:
Object
  • Object
show all
Defined in:
lib/flows/shared_context_pipeline/track_list.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTrackList

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of TrackList.

Since:

  • 0.4.0



7
8
9
10
# File 'lib/flows/shared_context_pipeline/track_list.rb', line 7

def initialize
  @tracks = { main: Track.new(:main) }
  @current_track = :main
end

Instance Attribute Details

#current_trackObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0



5
6
7
# File 'lib/flows/shared_context_pipeline/track_list.rb', line 5

def current_track
  @current_track
end

Instance Method Details

#add_step(step) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0



21
22
23
# File 'lib/flows/shared_context_pipeline/track_list.rb', line 21

def add_step(step)
  @tracks[@current_track].add_step(step)
end

#first_step_nameObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0



25
26
27
# File 'lib/flows/shared_context_pipeline/track_list.rb', line 25

def first_step_name
  @tracks[:main].first_step_name
end

#initialize_dup(_other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0



12
13
14
# File 'lib/flows/shared_context_pipeline/track_list.rb', line 12

def initialize_dup(_other)
  @tracks = @tracks.transform_values(&:dup)
end

#main_track_empty?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 0.4.0



29
30
31
# File 'lib/flows/shared_context_pipeline/track_list.rb', line 29

def main_track_empty?
  @tracks[:main].empty?
end

#switch_track(track_name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0



16
17
18
19
# File 'lib/flows/shared_context_pipeline/track_list.rb', line 16

def switch_track(track_name)
  @tracks[track_name] ||= Track.new(track_name)
  @current_track = track_name
end

#to_flow(method_source) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

Since:

  • 0.4.0



41
42
43
44
45
46
47
48
# File 'lib/flows/shared_context_pipeline/track_list.rb', line 41

def to_flow(method_source)
  raise NoStepsError, method_source if main_track_empty?

  Flows::Flow.new(
    start_node: first_step_name,
    node_map: to_node_map(method_source)
  )
end

#to_node_map(method_source) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0



33
34
35
36
37
38
39
# File 'lib/flows/shared_context_pipeline/track_list.rb', line 33

def to_node_map(method_source)
  @tracks.reduce({}) do |node_map, (_, track)|
    node_map.merge!(
      track.to_node_map(method_source)
    )
  end
end