Sha256: b6098a694380afbc9983dad11f334b30c79eb7c79da27a780ec48bef78e80116
Contents?: true
Size: 742 Bytes
Versions: 6
Compression:
Stored size: 742 Bytes
Contents
# frozen_string_literal: true require_relative '../converter' module TTY class ProgressBar # Used by {Pipeline} to format :byte and :current_byte tokens # # @api private class ByteFormatter MATCHER = /(:current_byte|:byte)\b/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 def format(value) bytes = Converter.to_bytes(@progress.current) value.gsub(MATCHER, bytes) end end # ByteFormatter end # ProgressBar end # TTY
Version data entries
6 entries across 6 versions & 1 rubygems