DEV Community

chair
chair

Posted on • Edited on

1

Ruby progressbar template

Use this template for your progressbar needs in ruby. Highly modifiable, always useful, easy to forget. The Ruby progressbar is...a tool you can use.

  • Up top in your file, require the ruby-progressbar gem
  • Construct a query worth tracking the progress of
  • Use the progressbar template below
  • Enjoy peace of mind knowing exactly how long your process will take
  • Modify the code below to fit your use case
require 'ruby-progressbar'

query = Person.where.not(last_name: "Bigalow")

progress = ProgressBar.create(
  total: query.count,
  format: "Progress: %a <%B> %p%% %t",
  smoothing: 0.5
)

query.find_each do |person|
 progress.increment

 person.update!(first_name: "Duece")
end
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay