class

Crab::Bar

Inherits Crab::Renderable / Reference / Object

A class to handle the progress of a task (Only used in progress.cr)

Constructors

new(width : Int32 = 50, text : String = "", total : Int32 = 100, current : Int32 = 0, color : String = "default")

Create a new progress bar The parameters are:

  • width: The width of the bar (default: 50)
  • text: The text to display before the bar (default: "") (max 15 characters)
  • total: The total number of units in the bar (default: 100)
  • current: The current number of units in the bar (default: 0)
  • color: The color of the bar (default: "default") (can be any color supported by Crab::Ansi_Parser, including r,g,b formats)
Source

Instance methods

color
Source
color=(color : String)
Source
current
Source
current=(current : Int32)
Source
render

Render the Bar to a String to be Parsed by an Crab::Ansi_Parser, if possible do not call directly Prefer to use the Crab::Progress class to handle progress bars

Source
text
Source
text=(text : String)
Source
total
Source
total=(total : Int32)
Source
width
Source
width=(width : Int32)
Source