Class: CLI::UI::Widgets::Status

Inherits:
Base
  • Object
show all
Defined in:
lib/cli/ui/widgets/status.rb

Constant Summary collapse

ARGPARSE_PATTERN =
%r{
  \A (?<succeeded> \d+)
  :  (?<failed>    \d+)
  :  (?<working>   \d+)
  :  (?<pending>   \d+) \z
}x
OPEN =

e.g. “1:23:3:404”

Color::RESET.code + Color::BOLD.code + '[' + Color::RESET.code
CLOSE =
Color::RESET.code + Color::BOLD.code + ']' + Color::RESET.code
ARROW =
Color::RESET.code + Color::GRAY.code + '' + Color::RESET.code
COMMA =
Color::RESET.code + Color::GRAY.code + ',' + Color::RESET.code
SPINNER_STOPPED =
''
EMPTY_SET =
''

Instance Method Summary collapse

Methods inherited from Base

argparse_pattern, call, #initialize

Constructor Details

This class inherits a constructor from CLI::UI::Widgets::Base

Instance Method Details

#renderObject


22
23
24
25
26
27
28
29
# File 'lib/cli/ui/widgets/status.rb', line 22

def render
  if zero?(@succeeded) && zero?(@failed) && zero?(@working) && zero?(@pending)
    Color::RESET.code + Color::BOLD.code + EMPTY_SET + Color::RESET.code
  else
    #   [          0✓            ,         2✗          ◂         3⠼           ◂         4⌛︎           ]
    "#{OPEN}#{succeeded_part}#{COMMA}#{failed_part}#{ARROW}#{working_part}#{ARROW}#{pending_part}#{CLOSE}"
  end
end