Class: TTY::ProgressBar::TotalFormatter Private

Inherits:
Object
  • Object
show all
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

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.

Parameters:

  • value (Object)

Returns:

  • (Boolean)


22
23
24
# File 'lib/tty/progressbar/formatter/total.rb', line 22

def matches?(value)
  !!(value.to_s =~ MATCHER)
end