Class: TreasureData::Command::TimeBasedDownloadProgressIndicator
- Inherits:
-
Object
- Object
- TreasureData::Command::TimeBasedDownloadProgressIndicator
- Defined in:
- lib/td/command/common.rb
Instance Method Summary collapse
- #finish ⇒ Object
-
#initialize(msg, start_time, periodicity = 2) ⇒ TimeBasedDownloadProgressIndicator
constructor
A new instance of TimeBasedDownloadProgressIndicator.
- #update ⇒ Object
Constructor Details
#initialize(msg, start_time, periodicity = 2) ⇒ TimeBasedDownloadProgressIndicator
Returns a new instance of TimeBasedDownloadProgressIndicator.
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'lib/td/command/common.rb', line 378 def initialize(msg, start_time, periodicity = 2) require 'ruby-progressbar' @start_time = start_time @last_time = start_time @periodicity = periodicity @progress_bar = ProgressBar.create( title: msg, total: nil, format: formated_with_elasped_time(0), output: $stdout, unknown_progress_animation_steps: [' '], ) (formated_with_elasped_time(Command.humanize_elapsed_time(@start_time, @start_time))) end |
Instance Method Details
#finish ⇒ Object
406 407 408 409 |
# File 'lib/td/command/common.rb', line 406 def finish # NOTE %B is for clear terminal line ("%t: done %B") end |
#update ⇒ Object
396 397 398 399 400 401 402 403 404 |
# File 'lib/td/command/common.rb', line 396 def update if (time = Time.now.to_i) - @last_time >= @periodicity (formated_with_elasped_time(Command.humanize_elapsed_time(@start_time, time))) @last_time = time true else false end end |