class XCPerfect::Bar

Bar is a “progress bar” that is used to represent the code coverage percentage

Constants

BLOCK
BLOCK_ASCII

Public Class Methods

create(percentage, bar_length, color, ascii) click to toggle source
# File lib/xcperfect/bar.rb, line 11
def self.create(percentage, bar_length, color, ascii)
  @colorize = color
  block_symbol = ascii ? BLOCK_ASCII : BLOCK

  progress_length = (bar_length * percentage).round
  filled = block_symbol * progress_length
  remaining = red('-' * (bar_length - progress_length))

  color_func = color_for(percentage)
  bar = color_func.call(filled) + remaining
  "|#{bar}| #{percentage * 100} %"
end