Module: Animation
- Included in:
- CodingChallenge::Commands::Start
- Defined in:
- lib/coding_challenge/commands/util/animation.rb
Instance Method Summary collapse
- #intro_loading_bars_animation ⇒ Object
- #intro_title_animation ⇒ Object
- #loading_animation(text = 'Loading...', delay = 3) ⇒ Object
- #type_effect(text) ⇒ Object
Instance Method Details
#intro_loading_bars_animation ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/coding_challenge/commands/util/animation.rb', line 8 def = TTY::ProgressBar::Multi.new('Prepping for awesomeness 😎 [:bar] :percent', head: '>') = .register('Crossing my fingers I get a job :percent [:bar] ', total: 30, head: '>', output: $stdout) = .register("Doin' a motivation dance :percent [:bar] ", total: 30, head: '>', output: $stdout) .start th1 = Thread.new { 30.times { sleep(0.075); .advance } } th2 = Thread.new { 30.times { sleep(0.05); .advance } } [th1, th2].each(&:join) end |
#intro_title_animation ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/coding_challenge/commands/util/animation.rb', line 20 def intro_title_animation path_dirs = __dir__.split('/') path_dirs.pop greeting_title_ascii_file = File.open("#{path_dirs.join('/')}/text/greeting_title_ascii.txt") greeting_title_ascii_str = greeting_title_ascii_file.read system "echo '#{greeting_title_ascii_str}' | lolcat -a -d 1" end |
#loading_animation(text = 'Loading...', delay = 3) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/coding_challenge/commands/util/animation.rb', line 29 def loading_animation(text = 'Loading...', delay = 3) spinner = TTY::Spinner.new("[:spinner] #{text}", format: :pulse_2, clear: true) spinner.auto_spin sleep(delay) spinner.stop end |
#type_effect(text) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/coding_challenge/commands/util/animation.rb', line 36 def type_effect(text) i = 0 text.length.times do print text[i] i += 1 sleep(0.025) end puts ' ' end |