Class: SwarmCLI::UI::Components::Divider

Inherits:
Object
  • Object
show all
Defined in:
lib/swarm_cli/ui/components/divider.rb

Overview

Divider rendering for visual separation Only horizontal lines - no side borders per design constraint

Instance Method Summary collapse

Constructor Details

#initialize(pastel:, terminal_width: 80) ⇒ Divider

Returns a new instance of Divider.



9
10
11
12
# File 'lib/swarm_cli/ui/components/divider.rb', line 9

def initialize(pastel:, terminal_width: 80)
  @pastel = pastel
  @terminal_width = terminal_width
end

Instance Method Details

#bottom(char: "─", color: :dim) ⇒ Object

Bottom border only (no sides) Content here ────────────────────────────────────────────────────────────



51
52
53
# File 'lib/swarm_cli/ui/components/divider.rb', line 51

def bottom(char: "", color: :dim)
  @pastel.public_send(color, char * @terminal_width)
end

#event(indent: 0, char: "·") ⇒ Object

Event separator (dotted, indented) ····························································



22
23
24
25
26
# File 'lib/swarm_cli/ui/components/divider.rb', line 22

def event(indent: 0, char: "·")
  prefix = "  " * indent
  line = char * 60
  "#{prefix}#{@pastel.dim(line)}"
end

#full(char: "─", color: :dim) ⇒ Object

Full-width divider line ────────────────────────────────────────────────────────────



16
17
18
# File 'lib/swarm_cli/ui/components/divider.rb', line 16

def full(char: "", color: :dim)
  @pastel.public_send(color, char * @terminal_width)
end

#section(label, char: "─", color: :dim) ⇒ Object

Section divider with centered label ───────── Section Name ─────────



30
31
32
33
34
35
36
37
38
39
# File 'lib/swarm_cli/ui/components/divider.rb', line 30

def section(label, char: "", color: :dim)
  label_width = label.length + 2 # Add spaces around label
  total_line_width = @terminal_width
  side_width = (total_line_width - label_width) / 2

  left = char * side_width
  right = char * (total_line_width - label_width - side_width)

  @pastel.public_send(color, "#{left} #{label} #{right}")
end

#top(char: "─", color: :dim) ⇒ Object

Top border only (no sides) ──────────────────────────────────────────────────────────── Content here



44
45
46
# File 'lib/swarm_cli/ui/components/divider.rb', line 44

def top(char: "", color: :dim)
  @pastel.public_send(color, char * @terminal_width)
end