Skip to content

Instantly share code, notes, and snippets.

@tlux
Created September 12, 2012 21:00
Show Gist options
  • Save tlux/3709895 to your computer and use it in GitHub Desktop.
Save tlux/3709895 to your computer and use it in GitHub Desktop.
Check string numericality
class String
def fixnum?
!/^[\d]+$/.match(self).nil?
end
def float?
!/^[\d]+\.[\d]+?$/.match(self).nil?
end
def numeric?
fixnum? || float?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment