Class: Legion::TTY::Components::ToolPanel
- Inherits:
-
Object
- Object
- Legion::TTY::Components::ToolPanel
- Defined in:
- lib/legion/tty/components/tool_panel.rb
Constant Summary collapse
- ICONS =
{ running: "\u27F3", complete: "\u2713", failed: "\u2717" }.freeze
- STATUS_COLORS =
{ running: :info, complete: :success, failed: :error }.freeze
Instance Method Summary collapse
- #collapse ⇒ Object
- #expand ⇒ Object
-
#expanded? ⇒ Boolean
rubocop:enable Metrics/ParameterLists.
-
#initialize(name:, args:, status: :running, duration: nil, result: nil, error: nil) ⇒ ToolPanel
constructor
rubocop:disable Metrics/ParameterLists.
- #render(width: 80) ⇒ Object
- #toggle ⇒ Object
Constructor Details
#initialize(name:, args:, status: :running, duration: nil, result: nil, error: nil) ⇒ ToolPanel
rubocop:disable Metrics/ParameterLists
22 23 24 25 26 27 28 29 30 |
# File 'lib/legion/tty/components/tool_panel.rb', line 22 def initialize(name:, args:, status: :running, duration: nil, result: nil, error: nil) @name = name @args = args @status = status @duration = duration @result = result @error = error @expanded = status == :failed end |
Instance Method Details
#collapse ⇒ Object
41 42 43 |
# File 'lib/legion/tty/components/tool_panel.rb', line 41 def collapse @expanded = false end |
#expand ⇒ Object
37 38 39 |
# File 'lib/legion/tty/components/tool_panel.rb', line 37 def @expanded = true end |
#expanded? ⇒ Boolean
rubocop:enable Metrics/ParameterLists
33 34 35 |
# File 'lib/legion/tty/components/tool_panel.rb', line 33 def @expanded end |
#render(width: 80) ⇒ Object
49 50 51 52 53 |
# File 'lib/legion/tty/components/tool_panel.rb', line 49 def render(width: 80) lines = [header_line(width)] lines << body_line if @expanded && body_content lines.join("\n") end |
#toggle ⇒ Object
45 46 47 |
# File 'lib/legion/tty/components/tool_panel.rb', line 45 def toggle @expanded = !@expanded end |