Class: XCPerfect::Bar
Overview
Bar is a “progress bar” that is used to represent the code coverage percentage
Constant Summary collapse
- BLOCK =
'█'.freeze
- BLOCK_ASCII =
'#'.freeze
Constants included from ANSI
ANSI::COLORS, ANSI::EFFECT, ANSI::FORMATTED_MATCHER
Instance Attribute Summary
Attributes included from ANSI
Class Method Summary collapse
Methods included from ANSI
ansi_parse, applied_effects, color_for, colorize?, cyan, green, red, strip, white, yellow
Class Method Details
.create(percentage, bar_length, color, ascii) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/xcperfect/bar.rb', line 11 def self.create(percentage, , color, ascii) @colorize = color block_symbol = ascii ? BLOCK_ASCII : BLOCK progress_length = ( * percentage).round filled = block_symbol * progress_length remaining = red('-' * ( - progress_length)) color_func = color_for(percentage) = color_func.call(filled) + remaining "|#{}| #{percentage * 100} %" end |