Class: TreasureData::Command::TimeBasedDownloadProgressIndicator
- Inherits:
-
DownloadProgressIndicator
- Object
- DownloadProgressIndicator
- 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.
362 363 364 365 366 367 |
# File 'lib/td/command/common.rb', line 362 def initialize(msg, start_time, periodicity = 2) @start_time = start_time @last_time = start_time @periodicity = periodicity super(msg) end |
Instance Method Details
#finish ⇒ Object
381 382 383 |
# File 'lib/td/command/common.rb', line 381 def finish $stdout.puts "\r#{@base_msg}...done" + " " * 20 end |
#update ⇒ Object
369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/td/command/common.rb', line 369 def update if (time = Time.now.to_i) - @last_time >= @periodicity msg = "\r#{@base_msg}: #{Command.humanize_elapsed_time(@start_time, time)} elapsed" $stdout.print "\r" + " " * (msg.length + 10) $stdout.print msg @last_time = time true else false end end |