Class: AsciiParadise::ProgressBar
- Defined in:
- lib/ascii_paradise/animations/progress_bar.rb
Constant Summary collapse
- INTERVAL =
#
INTERVAL
How long we will wait. The larger, the slower the progress-bar will appear.
#
0.2
- START =
#
START
#
"\r["
- LENGTH =
#
The length of the AsciiBar comes next. The higher, the longer the bar.
#
N_TIMES = 50
Constants inherited from Animation
Instance Method Summary collapse
-
#initialize(run_already = true) ⇒ ProgressBar
constructor
# === initialize ========================================================================= #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#run ⇒ Object
# === run ========================================================================= #.
-
#run_the_progress_bar ⇒ Object
# === run_the_progress_bar ========================================================================= #.
Methods inherited from Animation
#ascii_files?, #dataset?, #delay?, #display, #display_the_frame, #do_clear?, #do_use_colour_spray, #do_use_disco_inferno, #do_use_half_colours, #do_use_rainbow_colours, #guess_filename, is_animated?, #is_animated?, #load_animated_ascii_files_from_this_directory, #load_ascii_files, #load_ascii_files_and_determine_the_dataset, #load_dataset, #mediumpurple, #parse_dataset_from_this_control_file, #return_filename, #return_the_name_to_the_proper_animation_directory_of_this_animated_component, run, #run_n_times?, #run_with_this_dataset, #run_with_this_dataset_while_waiting_for_keypress_events, #set_dataset, #set_delay, #set_run_n_times, #set_use_ascii_files_from_this_directory, #show_frame_at_this_position, #show_to_the_user_how_to_operate_the_keypress_interface, #sleep_with_the_default_delay, #use_disco_inferno?
Methods inherited from Base
animation_dir?, #animation_directory?, #clear_screen, #colour_parse_this_string, #debug?, #do_not_run_already, #do_not_use_clear, #do_use_random_colour, #do_wait_for_keypress_event, e, #e, #enable_debug, #is_animated?, #menu, #project_base_dir?, #register_sigint, #remove_trailing_ansci_escape_code, #report_how_many_animated_components_exist, #return_basename_of_this_file_without_the_extension, #return_random_colour, #rev, #royalblue, run, #set_use_this_colour, #sfancy, #sfile, #show_available_components, #show_help, #simp, #slategrey, #sort_files, #static_dir?, #steelblue, #swarn, #use_colours?
Constructor Details
#initialize(run_already = true) ⇒ ProgressBar
#
initialize
#
37 38 39 40 41 42 43 |
# File 'lib/ascii_paradise/animations/progress_bar.rb', line 37 def initialize( run_already = true ) register_sigint reset run if run_already end |
Instance Method Details
#reset ⇒ Object
#
reset
#
48 49 50 |
# File 'lib/ascii_paradise/animations/progress_bar.rb', line 48 def reset @length = LENGTH end |
#run ⇒ Object
#
run
#
77 78 79 |
# File 'lib/ascii_paradise/animations/progress_bar.rb', line 77 def run end |
#run_the_progress_bar ⇒ Object
#
run_the_progress_bar
#
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/ascii_paradise/animations/progress_bar.rb', line 55 def @length.times {|i| output_string = START.dup # Need .dup here because otherwise the START-string will be appended. @length.times {|x| # =================================================================== # # Next we build up our output string. This string will fluctate # at every interval. # =================================================================== # output_string << ( x == i && ( i % 2 == 0 && 'C'||'c')|| (x < i && '-' || ( x % 2 == 0 && ' '|| 'o' )) ) } print output_string+']' STDOUT.flush sleep INTERVAL } e end |