class Progress
- Progress
- Reference
- Object
Defined in:
progress.crprogress/version.cr
Constant Summary
-
CARRIAGE_RETURN =
'\r' -
DEFAULT_TEMPLATE =
"{label} {bar} {step} {percent} [{elapsed}]" -
EMPTY_CHAR =
" " -
FILLED_CHAR =
"=" -
GiB =
1024 * MiB -
KiB =
1024 -
LEFT_BORDER_CHAR =
"[" -
MiB =
1024 * KiB -
NEW_LINE =
'\n' -
PERCENT_MASK =
"%4.f%%" -
RIGHT_BORDER_CHAR =
"]" -
STEP_MASK =
"%5.1f" -
TEMPLATE_REGEX =
/{label}|{bar}|{total}|{step}|{percent}|{elapsed}/ -
TOTAL_MASK =
"%5.1f" -
VERSION =
"0.1.2"
Constructors
Instance Method Summary
-
#done? : Bool
Returns true if the progress bar is done, else false.
-
#elapsed_time : String
Returns the elapsed time since the progress bar was last initialized.
-
#init : Nil
Initializes the timer and render the progress bar.
-
#set(step : Num) : Nil
Sets the progress bar step directly.
-
#started? : Bool
Returns true if the progress bar is running, else false.
-
#tick(step : Num) : Nil
Ticks the progress bar by step.
Constructor Detail
def self.new(width : Num = 100_u64, total : Num = 100_u64, step : Num = 0_u64, left_border_char : String = LEFT_BORDER_CHAR, filled_char : String = FILLED_CHAR, empty_char : String = EMPTY_CHAR, right_border_char : String = RIGHT_BORDER_CHAR, label : String = "", template : String = DEFAULT_TEMPLATE, total_mask : String = TOTAL_MASK, step_mask : String = STEP_MASK, percent_mask : String = PERCENT_MASK, humanize_bytes : Bool = true, stream : IO::FileDescriptor = STDOUT)
#
Instance Method Detail
def elapsed_time : String
#
Returns the elapsed time since the progress bar was last initialized.
progress = Progress.new
sleep 5
progress.elapsed_time # => 00:05
Sets the progress bar step directly. If the value overflows the progress bar capacity, the remaining will be ignored.
progress = Progress.new(total: 10)
progress.set(10)
progress.done? # => true
def started? : Bool
#
Returns true if the progress bar is running, else false. This method has no effect right now, as it always return true.
Ticks the progress bar by step. The step can be either positive or negative.
progress = Progress.new(total: 10)
progress.tick(10)
progress.done? # => true