Skip to content

Instantly share code, notes, and snippets.

@kitwalker12
Last active August 29, 2015 13:56
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 kitwalker12/9085896 to your computer and use it in GitHub Desktop.
Save kitwalker12/9085896 to your computer and use it in GitHub Desktop.
check if string is float and/or whole number
def is_number?(str)
true if Float(str) rescue false
end
def prettify(str)
str = str.to_f
str.to_i == str ? str.to_i : str
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment