Class: Liri::Common::TtyProgressbar::TimeFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/common/tty_progressbar.rb

Overview

From

Instance Method Summary collapse

Instance Method Details

#call(value) ⇒ Object

specify how display string is formatted



62
63
64
65
66
# File 'lib/common/tty_progressbar.rb', line 62

def call(value) # specify how display string is formatted
  # access current progress bar instance to read start time
  elapsed = Duration.humanize(Time.now - progress.start_time, times_round: Liri.times_round, times_round_type: Liri.times_round_type)
  value.gsub(matcher, elapsed)   # replace :time token with a value
end