Class: Mutant::Reporter::CLI::ProgressBar Private

Inherits:
Object
  • Object
show all
Defined in:
lib/mutant/reporter/cli/progress_bar.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Visual progress bar renderer

Renders nextest-style progress bars like:

45/100 (45.0%) 

Constant Summary collapse

FILLED_CHAR =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"\u2588"
EMPTY_CHAR =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"\u2591"
DEFAULT_WIDTH =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

30

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(current:, total:, width: DEFAULT_WIDTH) ⇒ ProgressBar

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Build a progress bar with defaults

Parameters:

  • current (Integer)

    current progress value

  • total (Integer)

    total value

  • width (Integer) (defaults to: DEFAULT_WIDTH)

    bar width in characters

Returns:



47
48
49
50
51
52
53
54
55
# File 'lib/mutant/reporter/cli/progress_bar.rb', line 47

def self.build(current:, total:, width: DEFAULT_WIDTH)
  new(
    current:,
    total:,
    width:,
    filled_char: FILLED_CHAR,
    empty_char:  EMPTY_CHAR
  )
end

Instance Method Details

#percentageFloat

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Calculate percentage completion

Returns:

  • (Float)


34
35
36
37
38
# File 'lib/mutant/reporter/cli/progress_bar.rb', line 34

def percentage
  return 0.0 if total.zero?

  (current.to_f / total * 100)
end

#renderString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Render the progress bar string

Returns:

  • (String)


27
28
29
# File 'lib/mutant/reporter/cli/progress_bar.rb', line 27

def render
  "#{filled}#{empty}"
end