#Ducktyping: Does it walk like a duck? Does it quack like a duck?
if arg1.responds_to? :capitalize
puts "Then '#{arg1.capitalize}' must be a string.\n"
else
if arg1.responds_to? :modulo && arg1.responds_to? :numerator
puts "Then '#{arg1.to_s}' must be an integer.\n"
else
if arg1.responds_to? :modulo && arg1.responds_to? :truncate
puts "Then '#{arg1.to_s}' must be a float.\n"
end
end
end
Nice :) Actually I used this widget to make it work.
Update: I couldn't resist and I also implemented it in this wiki.