Class: Agentilda::Roster

Inherits:
Object
  • Object
show all
Defined in:
lib/agentilda/roster.rb

Overview

agentilda agents — who the specialists are and what each is offered work from. Reading one in full is Viewer's job: the definition file is already the whole truth, so agents describe opens it rather than restating it.

#list returns a string and prints nothing, the same bargain Reporter makes, so the caller decides where the text goes and the table stays pipeable.

Everything here is read from the definition files. Nothing about a specialty is restated in Ruby, because a second copy of "who does what" is a copy that drifts from the frontmatter the loop actually routes on.

Constant Summary collapse

HEADINGS =

Columns, so the header and the rows cannot drift apart.

["Agent", "Handles", "Advances to", "Model"].freeze
READ_ONLY =

What an agent with no advances_to is, in the one word that explains why run never offers it work.

"read-only"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(agents: Agents.new) ⇒ Roster

Returns a new instance of Roster.

Parameters:



25
26
27
# File 'lib/agentilda/roster.rb', line 25

def initialize(agents: Agents.new)
  @agents = agents
end

Instance Attribute Details

#agentsAgentilda::Agents (readonly)

Returns:



30
31
32
# File 'lib/agentilda/roster.rb', line 30

def agents
  @agents
end

Instance Method Details

#listString

One line per agent, in name order.

Returns:

  • (String)

    newline-terminated



35
36
37
38
39
40
# File 'lib/agentilda/roster.rb', line 35

def list
  all = agents.all
  return "No agent definitions in #{agents.dir}\n" if all.empty?

  [header(all), *all.map { |agent| row(agent, all) }].join("\n") + "\n"
end