Created
June 2, 2016 03:51
-
-
Save langsharpe/fcc5e9b4f4aac90d5037b131767572c1 to your computer and use it in GitHub Desktop.
Progress countdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# > ProgressCountDown.new.call { Model.where(state: [:pending, :waiting]).count } | |
# Things: |============== | (30693/224796) ETA: 03:37:1 | |
class ProgressCountDown | |
def call | |
total = yield | |
progress = | |
ProgressBar.create( | |
title: "Things", | |
total: total, | |
format: "%t: |%B| (%c/%C) %E", | |
) | |
value = total | |
while value > 0 | |
sleep 30 | |
value = yield | |
progress.progress = total - value | |
end | |
progress.finish | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment