class AsciiParadise::Counter
Constants
- BROWN
#¶ ↑
BROWN
¶ ↑#¶ ↑
- DEFAULT_COUNTDOWN_FROM
#¶ ↑
DEFAULT_COUNTDOWN_FROM
¶ ↑#¶ ↑
- N_PADDING
#¶ ↑
N_PADDING
¶ ↑#¶ ↑
Public Class Methods
[](i)
click to toggle source
new( countdown_from = nil, use_this_padding = N_PADDING, run_already = true )
click to toggle source
#¶ ↑
initialize¶ ↑
The second argument is the default padding to use.
#¶ ↑
# 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
Public Instance Methods
count_down(i = @countdown_from)
click to toggle source
#¶ ↑
count_down
¶ ↑
Use this method to count down. We start at 25 for now.
#¶ ↑
# 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 # Silent rescue. } end
reset()
click to toggle source
run()
click to toggle source
set_countdown_from(i = nil)
click to toggle source
#¶ ↑
set_countdown_from
¶ ↑
#¶ ↑
# File lib/ascii_paradise/animations/counter.rb, line 64 def set_countdown_from(i = nil) i = DEFAULT_COUNTDOWN_FROM if i.is_a? Symbol i = DEFAULT_COUNTDOWN_FROM if i.nil? @countdown_from = i.to_i # Must be Integer. end
Also aliased as: start_from, start_from=
set_padding_to_use(i)
click to toggle source