Class: AsciiParadise::Counter
Constant Summary
collapse
- N_PADDING =
3
- DEFAULT_COUNTDOWN_FROM =
#
DEFAULT_COUNTDOWN_FROM
#
25
- BROWN =
Colours::BROWN
Constants inherited
from Animation
Animation::RUN_N_TIMES
Class Method Summary
collapse
-
.[](i) ⇒ Object
# === Counter[] ========================================================================= #.
Instance Method Summary
collapse
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(countdown_from = nil, use_this_padding = N_PADDING, run_already = true) ⇒ Counter
#
initialize
The second argument is the default padding to use.
#
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/ascii_paradise/animations/counter.rb', line 39
def initialize(
countdown_from = nil,
use_this_padding = N_PADDING,
run_already = true
)
reset
set_countdown_from(countdown_from)
set_padding_to_use(use_this_padding)
case countdown_from
when :dont_run_yet
run_already = false
end
run if run_already
end
|
Class Method Details
.[](i) ⇒ Object
74
75
76
77
78
|
# File 'lib/ascii_paradise/animations/counter.rb', line 74
def self.[](i)
ascii_counter = Counter.new(:dont_run_yet)
ascii_counter.start_from = i
ascii_counter.run
end
|
Instance Method Details
#count_down(i = @countdown_from) ⇒ Object
#
count_down
Use this method to count down. We start at 25 for now.
#
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/ascii_paradise/animations/counter.rb', line 85
def count_down(i = @countdown_from)
i.downto(0).each { |x|
_ = ( ('%'+@padding_to_use.to_s+'s') % x.to_s)
print @colour_to_use+R+_
STDOUT.flush
begin
sleep 1
rescue Interrupt
puts; exit
end }
end
|
#reset ⇒ Object
57
58
59
|
# File 'lib/ascii_paradise/animations/counter.rb', line 57
def reset
@colour_to_use = BROWN
end
|
#run ⇒ Object
110
111
112
|
# File 'lib/ascii_paradise/animations/counter.rb', line 110
def run
count_down
end
|
#set_countdown_from(i = nil) ⇒ Object
Also known as:
start_from, start_from=
#set_padding_to_use(i) ⇒ Object
101
102
103
104
105
|
# File 'lib/ascii_paradise/animations/counter.rb', line 101
def set_padding_to_use(i)
i = i.size if i.is_a? String
i = i.to_i
@padding_to_use = i
end
|