class TTY::ProgressBar::PercentFormatter

Used by {Pipeline} to format :percent token

@api private

Public Instance Methods

call(value) click to toggle source

Format :percent token

@param [String] value

the value to format

@api public

# File lib/tty/progressbar/formatter/percent.rb, line 19
def call(value)
  percent = @progress.width == 0 ? 100 : (@progress.ratio * 100).to_i
  display = @progress.indeterminate? ? "-" : percent.to_s
  value.gsub(matcher, "#{display}%")
end