class AsciiParadise::AnimatedProgressBar
Constants
- BACKTRACKING
BACKTRACKING
¶ ↑#¶ ↑
- Bottom
- BottomLeft
- BottomRight
- Check
- Left
- LightCheck
- MAX_VALUE
- Right
- STEP_SIZE
- STEP_TO
- Top
- TopLeft
#¶ ↑
The various constants - top left, top, top right and so forth.
These may be
Unicode
symbols.#¶ ↑
- TopRight
Attributes
progress[RW]
Public Class Methods
new( pad = ['','',''], io = $stdout )
click to toggle source
Public Instance Methods
finish()
click to toggle source
#¶ ↑
finish¶ ↑
#¶ ↑
# File lib/ascii_paradise/animations/animated_progress_bar.rb, line 99 def finish @io.print BACKTRACKING, @pad[0], TopLeft, Top * MAX_VALUE, TopRight, "\n", @pad[1], Left, "\e[44m", " " * MAX_VALUE, "\e[0m", Right, " ", Check, " \n", @pad[2], BottomLeft, Bottom * MAX_VALUE, BottomRight, "\n" @io.flush end
output_three_newlines()
click to toggle source
reset()
click to toggle source
run()
click to toggle source
update(progress = nil)
click to toggle source
#¶ ↑
update¶ ↑
The main method that will output the bar.
#¶ ↑
# File lib/ascii_paradise/animations/animated_progress_bar.rb, line 80 def update(progress = nil) @progress = progress if progress prog = @progress filled = (0.5 * prog).round free = MAX_VALUE - filled # ======================================================================= # # Next draw the box. # ======================================================================= # @io.print BACKTRACKING, @pad[0], TopLeft, Top * MAX_VALUE, TopRight, "\n", @pad[1], Left, "\e[44m", ' ' * filled, "\e[46m", ' ' * free, "\e[0m", Right, ' ', prog.round, "%\n", @pad[2], BottomLeft, Bottom * MAX_VALUE, BottomRight, N @io.flush end