DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Determine If A String Or Numeric Represents A Number In Ruby
# Determine if a String or Numeric represents a number
# From http://www.pixellatedvisions.com/2009/06/22/string-is-a-number#comment-67
def is_numeric? self.is_a?(Numeric) or (self.is_a?(String) and !!Float(self)) rescue false end




