Class: SwarmCLI::UI::State::AgentColorCache
- Inherits:
-
Object
- Object
- SwarmCLI::UI::State::AgentColorCache
- Defined in:
- lib/swarm_cli/ui/state/agent_color_cache.rb
Overview
Caches agent name → color assignments for consistent coloring
Constant Summary collapse
- PALETTE =
Professional color palette inspired by modern CLIs
[ :cyan, :magenta, :yellow, :blue, :green, :bright_cyan, :bright_magenta, ].freeze
Instance Method Summary collapse
-
#get(agent_name) ⇒ Object
Get color for agent (cached).
-
#initialize ⇒ AgentColorCache
constructor
A new instance of AgentColorCache.
-
#reset ⇒ Object
Reset cache (for testing).
Constructor Details
#initialize ⇒ AgentColorCache
Returns a new instance of AgentColorCache.
19 20 21 22 |
# File 'lib/swarm_cli/ui/state/agent_color_cache.rb', line 19 def initialize @cache = {} @next_index = 0 end |
Instance Method Details
#get(agent_name) ⇒ Object
Get color for agent (cached)
25 26 27 |
# File 'lib/swarm_cli/ui/state/agent_color_cache.rb', line 25 def get(agent_name) @cache[agent_name] ||= assign_next_color end |
#reset ⇒ Object
Reset cache (for testing)
30 31 32 33 |
# File 'lib/swarm_cli/ui/state/agent_color_cache.rb', line 30 def reset @cache.clear @next_index = 0 end |