Class: Mutant::Reporter::CLI::ProgressBar Private
- Inherits:
-
Object
- Object
- Mutant::Reporter::CLI::ProgressBar
- 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
-
.build(current:, total:, width: DEFAULT_WIDTH) ⇒ ProgressBar
private
Build a progress bar with defaults.
Instance Method Summary collapse
-
#percentage ⇒ Float
private
Calculate percentage completion.
-
#render ⇒ String
private
Render the progress bar string.
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
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
#percentage ⇒ Float
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
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 |
#render ⇒ String
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
27 28 29 |
# File 'lib/mutant/reporter/cli/progress_bar.rb', line 27 def render "#{filled}#{empty}" end |