Created
November 11, 2015 03:56
-
-
Save ceilwoo/26fc8149b7689f5556cb to your computer and use it in GitHub Desktop.
terminal countdown timer
This file contains 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
require 'time' | |
countdown_time = ARGV[0] | |
puts "-- Input Countdown time: XX:XX:XX ---" if !countdown_time | |
t = Time.parse(countdown_time) | |
seconds = (t.hour * 60 * 60 + t.min * 60 + t.sec).to_i | |
while (seconds!=0) do | |
print " " + Time.at(seconds).utc.strftime("%H:%M:%S") | |
print "\r" | |
sleep 1 | |
seconds -= 1 | |
end | |
puts "\n" | |
`say "Countdown End"` if /darwin/ =~ RUBY_PLATFORM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment