class RatatuiRuby::Gauge
Displays a standard progress bar.
Long-running tasks create anxiety. Users need to know that the system is working and how much is left to do.
This widget visualizes completion. It fills a bar based on a percentage.
Use it for downloads, installations, or processing jobs.
Examples
Gauge.new( ratio: 0.75, label: "75%", gauge_style: Style.new(fg: :green) )
Attributes
Optional wrapping block.
Style applied specifically to the filled bar portion (optional).
Text label to display (optional).
If nil, it often displays the percentage automatically depending on renderer logic, but explicit labels are preferred.
Progress ratio from 0.0 to 1.0.
Base style applied to the entire gauge background (optional).
Whether to use Unicode block characters (true) or ASCII characters (false). Default is false (ASCII) to be conservative, though Ratatui defaults to true.
Public Class Methods
Source
# File lib/ratatui_ruby/schema/gauge.rb, line 60 def initialize(ratio: nil, percent: nil, label: nil, style: nil, gauge_style: nil, block: nil, use_unicode: true) if percent ratio = Float(percent) / 100.0 end ratio = Float(ratio || 0.0) super(ratio:, label:, style:, gauge_style:, block:, use_unicode:) end
Creates a new Gauge.
- ratio
-
Float (0.0 - 1.0).
- percent
-
Integer (0 - 100), alternative to ratio.
- label
-
String (optional).
- style
-
Styleobject for the background (optional). gauge_style-
Styleobject for the filled bar (optional). - block
-
Blockwidget (optional). use_unicode-
Boolean (default: true).