Class: TreasureData::Command::TimeBasedDownloadProgressIndicator

Inherits:
DownloadProgressIndicator show all
Defined in:
lib/td/command/common.rb

Instance Method Summary collapse

Constructor Details

#initialize(msg, start_time, periodicity = 2) ⇒ TimeBasedDownloadProgressIndicator

Returns a new instance of TimeBasedDownloadProgressIndicator.



336
337
338
339
340
341
# File 'lib/td/command/common.rb', line 336

def initialize(msg, start_time, periodicity = 2)
  @start_time = start_time
  @last_time = start_time
  @periodicity = periodicity
  super(msg)
end

Instance Method Details

#finishObject



355
356
357
# File 'lib/td/command/common.rb', line 355

def finish
  puts "\r#{@base_msg}...done" + " " * 20
end

#updateObject



343
344
345
346
347
348
349
350
351
352
353
# File 'lib/td/command/common.rb', line 343

def update
  if (time = Time.now.to_i) - @last_time >= @periodicity
    msg = "\r#{@base_msg}: #{Command.humanize_elapsed_time(@start_time, time)} elapsed"
    print "\r" + " " * (msg.length + 10)
    print msg
    @last_time = time
    true
  else
    false
  end
end