Skip to content

Instantly share code, notes, and snippets.

@thomasjslone
Last active May 3, 2022 20:00
Show Gist options
  • Save thomasjslone/86d2cdcb37681cd602390cfb0a26e7b7 to your computer and use it in GitHub Desktop.
Save thomasjslone/86d2cdcb37681cd602390cfb0a26e7b7 to your computer and use it in GitHub Desktop.
get st nd rd and th after numbers
def surname
int=self.to_s
if int.to_s=="0";int="0"
elsif int[-2..-1]=="11" or int[-2..-1] =="12" or int[-2..-1] =="13"
int<<"th"
elsif int[-1]=="1";int<<"st"
elsif int[-1]=="2";int<<"nd"
elsif int[-1]=="3";int<<"rd"
else;int<<"th"
end
return int
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment