Class: TTY::ProgressBar::ByteRateFormatter Private
- Inherits:
-
Object
- Object
- TTY::ProgressBar::ByteRateFormatter
- Defined in:
- lib/tty/progressbar/formatter/byte_rate.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 :byte_rate 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.
/:byte_rate/i
Instance Method Summary collapse
-
#format(value) ⇒ Object
Format :byte_rate token.
-
#initialize(progress) ⇒ ByteRateFormatter
constructor
private
A new instance of ByteRateFormatter.
-
#matches?(value) ⇒ Boolean
private
Determines whether this formatter is applied or not.
Constructor Details
#initialize(progress) ⇒ ByteRateFormatter
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 ByteRateFormatter.
13 14 15 |
# File 'lib/tty/progressbar/formatter/byte_rate.rb', line 13 def initialize(progress) @progress = progress end |
Instance Method Details
#format(value) ⇒ Object
Format :byte_rate token
34 35 36 37 |
# File 'lib/tty/progressbar/formatter/byte_rate.rb', line 34 def format(value) formatted = Converter.to_bytes(@progress.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/byte_rate.rb', line 24 def matches?(value) !!(value.to_s =~ MATCHER) end |