class RemiLib::Console::ProgressBar(T)

Overview

A console-based progress bar. This uses ANSI control characters to draw the bar on one line.

Defined in:

remilib/console/progress-bar.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(label : String, max : T, output : IO = STDOUT) #

[View source]

Instance Method Detail

def addEllipses=(addEllipses : Bool) #

When true (the default), ellipses ("...") will be added to a clipped label if possible.


[View source]
def addEllipses? : Bool #

When true (the default), ellipses ("...") will be added to a clipped label if possible.


[View source]
def allowOver100=(allowOver100 : Bool) #

When false, then percentages that are above 100 are capped at 100. The default is true.


[View source]
def allowOver100? : Bool #

When false, then percentages that are above 100 are capped at 100. The default is true.


[View source]
def done : Nil #

Refreshes the bar, then prints a newline to the output and sets #done? to true. Calling this more than once is effectively a non-op.


[View source]
def done? : Bool #

When true, then the progress bar is finished and will not refresh itself anymore or allow changes to its properties.


[View source]
def label=(newLabel : String) : Nil #

Changes the label of the progress bar. This will automatically redraw the bar unless #noAutoRefresh is true.


[View source]
def labelWidth : UInt32 #

The maximum width for the progress bar label. If this is 0, then the max width is computed to be 1/5th of the width of the console.


[View source]
def labelWidth=(value : Int) : Nil #

Changes the label width. This cannot be negative. This will automatically redraw the bar unless #noAutoRefresh is true.


[View source]
def max : T #

The max number of steps.


[View source]
def max=(newMax : T) : Nil #

Changes the maximum value of the progress bar. This cannot be zero or negative.

If the new maximum is greater than the current #step, then the current #step is set to the new maximum.

This will automatically redraw the bar unless #noAutoRefresh is true.


[View source]
def noAutoRefresh=(noAutoRefresh : Bool) #

When true, the progress bar will not be redrawn automatically, and will only be redrawn when #refresh is called, or when #done is called. The default is false.


[View source]
def noAutoRefresh? : Bool #

When true, the progress bar will not be redrawn automatically, and will only be redrawn when #refresh is called, or when #done is called. The default is false.


[View source]
def postLabel : String | Nil #

An optional label that can be printed after the percentage at the end of the progress bar. If this is nil, then no extra label is printed. This can be up to #postLabelWidth characters long.


[View source]
def postLabel=(newLabel : String) : Nil #

Changes the post-bar label of the progress bar. This is printed after the percentage. This will automatically redraw the bar unless #noAutoRefresh is true.


[View source]
def postLabelWidth : UInt32 #

The maximum width for the progress bar's post-bar label. If this is 0, then the max width is computed to be 1/5th of the width of the console.


[View source]
def postLabelWidth=(value : Int) : Nil #

Changes the post-bar label width. This cannot be negative. This will automatically redraw the bar unless #noAutoRefresh is true.


[View source]
def pump : Nil #

Increases the step by one, then refreshes the bar. This will automatically redraw the bar unless #noAutoRefresh is true.


[View source]
def refresh : Nil #

Re-draws the progress bar. This can be called even when #done? is true.


[View source]
def step : T #

The current step.


[View source]
def step=(val : T) : Nil #

Sets the step to val, then refreshes the bar. val cannot be less than zero. If it is greater than #max, then it is clamped to #max. This will automatically redraw the bar unless #noAutoRefresh is true.


[View source]