Class: TTY::ProgressBar::TotalByteFormatter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/progressbar/formatter/total_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 :total_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.

/:total_byte/i.freeze

Instance Method Summary collapse

Constructor Details

#initialize(progress, *args, &block) ⇒ TotalByteFormatter

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 TotalByteFormatter.



13
14
15
# File 'lib/tty/progressbar/formatter/total_byte.rb', line 13

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.



28
29
30
31
# File 'lib/tty/progressbar/formatter/total_byte.rb', line 28

def format(value)
  bytes = Converter.to_bytes(@progress.total)
  value.gsub(MATCHER, bytes)
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)


24
25
26
# File 'lib/tty/progressbar/formatter/total_byte.rb', line 24

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