Created
August 19, 2014 12:01
-
-
Save DriftwoodJP/cacf349631831168439c to your computer and use it in GitHub Desktop.
Mac に数字を読み上げてもらうビンゴ抽選器をつくる | http://www.d-wood.com/blog/2014/08/22_6662.html
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 'readline' | |
def notification(message, title='Bingo Machine', subtitle='', sound='Glass') | |
[message, title, subtitle, sound].each{|arg| arg.gsub!(/"/, '\\\\\"')} | |
scpt = 'display notification "%s"' % message | |
scpt << ' with title "%s"' % title | |
scpt << ' subtitle "%s"' % subtitle unless subtitle.empty? | |
scpt << ' sound name "%s"' % sound unless sound.empty? | |
system %|osascript -e "#{scpt.gsub(/"/, '\"')}"| | |
sleep 0.5 | |
system %|osascript -e "say #{message}"| | |
end | |
a = (1..75).to_a.shuffle | |
print('> Press enter to start!', "\n") | |
a.each { |num| | |
buf = Readline.readline('> ', true) | |
break if buf == 'q' | |
print('> ', num, "\n") | |
notification num.to_s | |
} | |
print("\n", '> Finish!', "\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment