Skip to content

Instantly share code, notes, and snippets.

@leejones
Last active December 23, 2015 07:29
Show Gist options
  • Save leejones/6601102 to your computer and use it in GitHub Desktop.
Save leejones/6601102 to your computer and use it in GitHub Desktop.
dot dot dot - simple loading indicator for the console
class DotDot
def self.dot(starting_text = "Loading", completed_text = "Done!")
print starting_text
thread = Thread.new { loop { print '.'; sleep 1 } }
yield if block_given?
Thread.kill(thread)
print "\n"
puts completed_text
end
end
DotDot.dot do
  # run stuff that takes a long time
  require 'config/environment'
end
Loading....................
Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment