Skip to content

Projectors

Jeff Felchner edited this page Mar 4, 2023 · 1 revision

Sometimes when you're tracking progress, you might have some items which take significantly longer than others to complete. When this is the case, the ETA gauge can vary wildly from increment to increment.

RUBY PROGRESS BAR TO THE RESCUE!

"Projectors" are the concept we've decided on to estimate how long each increment of progress will take for all subsequent items on the bar. Projectors try to take into account varying factors to make this decision. Because one size does not fit all, we have the ability to use different projectors for different purposes.

How To Use Projectors

Note: Currently there is only one type of projector, but there are more coming soon.

Projectors are set during bar creation as an option like so:

ProgressBar.create(
  :projector => {
    :type     => 'smoothed',
    :strength => 0.1
  }
)

Using type will decide on which projector to inject into the estimation process. Each projector will have its own options that can be passed in alongside the type.

The default type is smoothed and the default strength is 0.1.

Types Of Projectors

Smoothed

Thanks to @L2G and 'the maths' your progress bar will then use an exponentially smoothed average rather than a linear one.

Usage

ProgressBar.create(
  :projector => {
    :type     => 'smoothed',
    :strength => 0.1
  }
)

Projector Options

strength

A value of 0.0 means no smoothing and is equivalent to the classic behavior. A value of 1.0 is the maximum amount of smoothing. Any values between those two are valid. The default value is 0.1.