Skip to content

Instantly share code, notes, and snippets.

@langsharpe
Created June 2, 2016 03:51
Show Gist options
  • Save langsharpe/fcc5e9b4f4aac90d5037b131767572c1 to your computer and use it in GitHub Desktop.
Save langsharpe/fcc5e9b4f4aac90d5037b131767572c1 to your computer and use it in GitHub Desktop.
Progress countdown
# > 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