Does a Command exist for Proper Names?

I am taking in a dataset of names but want to print them out nicely.
Some of them are all caps, others have none. While I found the string
class for capitalize, it only catches the first letter of the first
name.

Since you get things like Alex O’Brien or Tim R La Punta I could write
up something that acknowledges these cases and caps anything after a
space or quote, but was wondering if there was anything built in to use.

I am taking in a dataset of names but want to print them out nicely.
Some of them are all caps, others have none. While I found the string
class for capitalize, it only catches the first letter of the first
name.

Since you get things like Alex O’Brien or Tim R La Punta I could write
up something that acknowledges these cases and caps anything after a
space or quote, but was wondering if there was anything built in to use.

“Tim R la PUnta”.downcase.titlecase
=> “Tim R La Punta”

Perfect! Thanks for the help. Titlecase eh? Who woulda thought.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs