Skip to content

Instantly share code, notes, and snippets.

@tooky
Created September 22, 2008 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tooky/11991 to your computer and use it in GitHub Desktop.
Save tooky/11991 to your computer and use it in GitHub Desktop.
RESULTS = %w(H H H H H H A A A A A D)
def result
RESULTS[rand(RESULTS.length)]
end
require 'readline'
def prompt(prompt="> ")
input = nil
lines = []
prompt += " " unless prompt =~ /\s$/
loop do
input = Readline.readline(prompt, true)
break if input == "."
lines.push input
end
return lines
end
fixtures = prompt
results = fixtures.map do |fixture|
if fixture.empty?
fixture
else
fixture + result
end
end
puts results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment