Class: SwarmCLI::UI::State::DepthTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/swarm_cli/ui/state/depth_tracker.rb

Overview

Tracks agent depth for hierarchical indentation display

Instance Method Summary collapse

Constructor Details

#initializeDepthTracker

Returns a new instance of DepthTracker.



8
9
10
11
# File 'lib/swarm_cli/ui/state/depth_tracker.rb', line 8

def initialize
  @depths = {}
  @seen_agents = []
end

Instance Method Details

#get(agent_name) ⇒ Object

Get indentation depth for agent



14
15
16
# File 'lib/swarm_cli/ui/state/depth_tracker.rb', line 14

def get(agent_name)
  @depths[agent_name] ||= calculate_depth(agent_name)
end

#indent(agent_name, char: " ") ⇒ Object

Get indent string for agent



19
20
21
# File 'lib/swarm_cli/ui/state/depth_tracker.rb', line 19

def indent(agent_name, char: "  ")
  char * get(agent_name)
end

#resetObject

Reset tracker (for testing)



24
25
26
27
# File 'lib/swarm_cli/ui/state/depth_tracker.rb', line 24

def reset
  @depths.clear
  @seen_agents.clear
end