Class: Legion::CLI::Dashboard::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/cli/dashboard/renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(width: nil) ⇒ Renderer

Returns a new instance of Renderer.



7
8
9
# File 'lib/legion/cli/dashboard/renderer.rb', line 7

def initialize(width: nil)
  @width = width || default_width
end

Instance Method Details

#render(data) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/legion/cli/dashboard/renderer.rb', line 11

def render(data)
  lines = []
  lines << header_line(data)
  lines << separator
  lines << workers_section(data[:workers] || [])
  lines << separator
  lines << events_section(data[:events] || [])
  lines << separator
  lines << health_section(data[:health] || {})
  lines << separator
  lines << org_chart_section(data[:departments] || [])
  lines << footer_line(data[:fetched_at])
  lines.flatten.join("\n")
end