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

Inherits:
Base
  • Object
show all
Extended by:
T::Sig
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 =
''

Class Method Summary collapse

Instance Method Summary collapse

Methods included from T::Sig

sig

Methods inherited from Base

call, #initialize

Methods included from T::Helpers

#abstract!, #final!, #interface!, #mixes_in_class_methods, #sealed!

Constructor Details

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

Class Method Details

.argparse_patternObject



28
29
30
# File 'lib/cli/ui/widgets/status.rb', line 28

def argparse_pattern
  ARGPARSE_PATTERN
end

Instance Method Details

#renderObject



34
35
36
37
38
39
40
41
# File 'lib/cli/ui/widgets/status.rb', line 34

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