Class: TTY::ProgressBar::TotalFormatter Private
- Inherits:
-
Object
- Object
- TTY::ProgressBar::TotalFormatter
- Defined in:
- lib/tty/progressbar/formatter/total.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 :total 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.
/:total\b/i.freeze
Instance Method Summary collapse
- #format(value) ⇒ Object private
-
#initialize(progress, *args, &block) ⇒ TotalFormatter
constructor
private
A new instance of TotalFormatter.
-
#matches?(value) ⇒ Boolean
private
Determines whether this formatter is applied or not.
Constructor Details
#initialize(progress, *args, &block) ⇒ TotalFormatter
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 TotalFormatter.
11 12 13 |
# File 'lib/tty/progressbar/formatter/total.rb', line 11 def initialize(progress, *args, &block) @progress = progress end |
Instance Method Details
#format(value) ⇒ Object
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.
26 27 28 |
# File 'lib/tty/progressbar/formatter/total.rb', line 26 def format(value) value.gsub(MATCHER, @progress.total.to_s) 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.
22 23 24 |
# File 'lib/tty/progressbar/formatter/total.rb', line 22 def matches?(value) !!(value.to_s =~ MATCHER) end |