Sha256: 8e6347b4d0ce411eb2d2a5ccb9cbcc7e851d18e699fade0746abd64934760194
Contents?: true
Size: 841 Bytes
Versions: 6
Compression:
Stored size: 841 Bytes
Contents
# frozen_string_literal: true require_relative '../converter' module TTY class ProgressBar # Used by {Pipeline} to format :rate token # # @api private class RateFormatter MATCHER = /:rate/i.freeze def initialize(progress) @progress = progress end # Determines whether this formatter is applied or not. # # @param [Object] value # # @return [Boolean] # # @api private def matches?(value) !!(value.to_s =~ MATCHER) end # Format :rate token # # @param [String] value # the value being formatted # # @api public def format(value) formatted = Converter.to_seconds(@progress.rate) value.gsub(MATCHER, formatted) end end # RateFormatter end # ProgressBar end # TTY
Version data entries
6 entries across 6 versions & 1 rubygems