Class: TTY::ProgressBar::MeanByteFormatter Private
- Inherits:
-
Object
- Object
- TTY::ProgressBar::MeanByteFormatter
- Defined in:
- lib/tty/progressbar/formatter/mean_byte.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Used by Pipeline to format :mean_byte token
Constant Summary collapse
- MATCHER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/:mean_byte/i.freeze
Instance Method Summary collapse
-
#format(value) ⇒ Object
Format :rate token.
-
#initialize(progress) ⇒ MeanByteFormatter
constructor
private
A new instance of MeanByteFormatter.
-
#matches?(value) ⇒ Boolean
private
Determines whether this formatter is applied or not.
Constructor Details
#initialize(progress) ⇒ MeanByteFormatter
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of MeanByteFormatter.
13 14 15 |
# File 'lib/tty/progressbar/formatter/mean_byte.rb', line 13 def initialize(progress) @progress = progress end |
Instance Method Details
#format(value) ⇒ Object
Format :rate token
34 35 36 37 |
# File 'lib/tty/progressbar/formatter/mean_byte.rb', line 34 def format(value) formatted = Converter.to_bytes(@progress.mean_rate) value.gsub(MATCHER, formatted) end |
#matches?(value) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determines whether this formatter is applied or not.
24 25 26 |
# File 'lib/tty/progressbar/formatter/mean_byte.rb', line 24 def matches?(value) !!(value.to_s =~ MATCHER) end |