Created
October 24, 2013 08:39
-
-
Save shtaxxx/7133413 to your computer and use it in GitHub Desktop.
Timer using say command
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
#!/usr/bin/env ruby | |
USAGE = "$ ruby timer.rb time time ..." | |
if ARGV.length == 0 then | |
puts USAGE | |
exit | |
end | |
tl = [] | |
for arg in ARGV | |
tl << arg.to_i if arg.to_i > 0 | |
end | |
i=0 | |
while true | |
print "#{i} minutes.\n" | |
if tl.index(i) != nil then | |
system("say #{i} minutes."); | |
tl.delete(i) | |
end | |
break if tl.length == 0 | |
sleep 60 | |
i=i+1 | |
end | |
puts "#{i} minutes. Finish!" | |
system("say #{i} minutes. Finish!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment