-
-
Save rdammkoehler/2244283 to your computer and use it in GitHub Desktop.
Rich and John made a magic 8 ball using Vert.x ... and yeah could have used sample and the array but no-worky
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
require('vertx') | |
include Vertx | |
@server = HttpServer.new | |
@server.request_handler do | req | | |
premonition = [ 'Yes.', | |
'Yes, definitely.', | |
'As I see it yes.', | |
'It is certain.', | |
'Without a doubt.', | |
'It is decidedly so.', | |
'You may rely on it.', | |
'Outlook good.', | |
'Most likely', | |
'Signs point to yes.', | |
'My reply is no.', | |
'My sources say no.', | |
'Very doubtful.', | |
'Outlook not so good.', | |
'Dont count on it.', | |
'Cannot predict now', | |
'Ask again later.', | |
'Better not tell you now.', | |
'Cannot predict now.', | |
'Reply hazy. Try again.', | |
'Concentrate and ask again.' ] | |
req.response.end( premonition[ (rand * premonition.size).to_i ] ) | |
end.listen( 8080, 'localhost' ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As a curious note; we tested the distribution of the numbers returned by rand over 10,000,000 iterations; pretty good distribution;
harmonia 8-ball ruby eightball.rb