Skip to content

anonymous /gist:24e6877c35509289db91 secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
#!/usr/bin/env ruby
to_test = Enumerable
total = to_test.public_instance_methods.map(&:to_s)
guessed = []
puts "How many methods of #{to_test} can you name?"
puts "Press Control-D to exit"
print "1. "
while guessed.count < total.count && (guess = gets)
guess.chomp!
if total.include? guess
if guessed.include? guess
puts "You already got \"#{guess}\""
else
guessed << guess
puts "OK!"
end
else
puts "Sorry!"
end
print "#{guessed.count + 1}. " if guessed.count < total.count
end
missed = total - guessed
puts
puts missed.empty? ? "You got them all!" : "You missed:"
puts missed.sort.map { |name| "\t" + name }
puts "#{guessed.count} / #{total.count} methods named"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.