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.
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
#finish ⇒ Object
355 356 357 |
# File 'lib/td/command/common.rb', line 355 def finish puts "\r#{@base_msg}...done" + " " * 20 end |
#update ⇒ Object
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 |