ModernBar {parabar} | R Documentation |
ModernBar
Description
This is a concrete implementation of the abstract class Bar
using the progress::progress_bar
as engine for the progress bar.
Super class
parabar::Bar
-> ModernBar
Methods
Public methods
Method new()
Create a new ModernBar
object.
Usage
ModernBar$new()
Returns
An object of class ModernBar
.
Method create()
Create a progress bar.
Usage
ModernBar$create(total, initial, ...)
Arguments
total
The total number of times the progress bar should tick.
initial
The starting point of the progress bar.
...
Additional arguments for the bar creation passed to
progress::progress_bar$new()
.
Returns
This method returns void. The resulting bar is stored in the private
field .bar
, accessible via the active binding engine
. Both the
private field and the active binding are defined in the super class
Bar
.
Method update()
Update the progress bar by calling
progress::progress_bar$update()
.
Usage
ModernBar$update(current)
Arguments
current
The position the progress bar should be at (e.g., 30 out of 100), usually the index in a loop.
Method terminate()
Terminate the progress bar by calling
progress::progress_bar$terminate()
.
Usage
ModernBar$terminate()
Method clone()
The objects of this class are cloneable with this method.
Usage
ModernBar$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
See Also
Bar
, BasicBar
, and BarFactory
.
Examples
# Create a modern bar instance.
bar <- ModernBar$new()
# Specify the number of ticks to be performed.
total <- 100
# Create the progress bar.
bar$create(total = total, initial = 0)
# Use the progress bar.
for (i in 1:total) {
# Sleep a bit.
Sys.sleep(0.02)
# Update the progress bar.
bar$update(i)
}
# Terminate the progress bar.
bar$terminate()