Last active
August 29, 2015 14:07
-
-
Save amitsaxena/689d29f23d01bd563839 to your computer and use it in GitHub Desktop.
Ruby text only spinner/loader/processing/progress indicators && some FUN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Loader for infinite time | |
["|", "/", "-", "\\"].each{|v| STDOUT.write "\r#{v}"; sleep 0.5} while 1 | |
# In case you want to run it for a few seconds (~ 20s in the example below) | |
10.times{ ["|", "/", "-", "\\"].each{|v| STDOUT.write "\r#{v}"; sleep 0.5} } | |
# Progress Bar | |
100.times{STDOUT.write "|"; sleep 0.1} | |
# Another kind of loading indicator | |
(f=rand(20); STDOUT.write "\r#{'|'*f}#{'#'*15}#{'|'*(20-f)}"; sleep 0.5) while 1 | |
# Dog drowning in sea waves ;) | |
(f=rand(10); STDOUT.write "\r#{'~'*f}^o^#{'~'*(20-f)}"; sleep 0.5) while 1 | |
# Travelling ship =P | |
101.times{ |i| STDOUT.write "\r#{'~'*i}\\____/#{'~'*(100-i)}"; sleep 0.2 } | |
# Ship rescuing the dog =) #heartWarmingStory | |
75.times{ |i| f=rand(17); STDOUT.write "\r#{'~'*f}^o^#{'~'*(17-f)}#{'~'*(75-i)}\\___/#{'~'*i}"; sleep 0.2 }; STDOUT.write "\r#{'~'*17}^o^\\___/#{'~'*75}"; sleep 2; 20.times{ |i| STDOUT.write "\r#{'~'*(19-i)}\\___/#{'~'*(i+76)}"; sleep 0.2 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment