-
-
Notifications
You must be signed in to change notification settings - Fork 131
Projectors
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.
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
.
Thanks to @L2G and 'the maths' your progress bar will then use an exponentially smoothed average rather than a linear one.
ProgressBar.create(
:projector => {
:type => 'smoothed',
:strength => 0.1
}
)
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
.