Skip to content

Instantly share code, notes, and snippets.

@madpilot
Created September 14, 2010 04:50
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 madpilot/578562 to your computer and use it in GitHub Desktop.
Save madpilot/578562 to your computer and use it in GitHub Desktop.
class SmokeyTheBear
def method_missing(symbol, *args)
responses = [ :me, :you ]
if responses.include?(symbol)
what_was_said = symbol.to_s
what_was_meant = responses.dup.delete_if { |r| r == symbol }.first.to_s
return "You chose '#{what_was_said}' referring to '#{what_was_meant}'. That is incorrect. The correct answer is '#{what_was_meant}'."
else
super
end
end
end
bear = SmokeyTheBear.new
puts bear.you
puts bear.me
puts bear.maggie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment