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.
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
# File 'lib/td/command/common.rb', line 387 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
415 416 417 418 |
# File 'lib/td/command/common.rb', line 415 def finish # NOTE %B is for clear terminal line ("%t: done %B") end |
#update ⇒ Object
405 406 407 408 409 410 411 412 413 |
# File 'lib/td/command/common.rb', line 405 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 |