> " mary-joe o'donnell ".downcase.gsub(/\b([a-z])/) { Regexp.last_match(1).capitalize }.strip
=> "Mary-Joe O'Donnell"
Source:
> " mary-joe o'donnell ".downcase.gsub(/\b([a-z])/) { Regexp.last_match(1).capitalize }.strip
=> "Mary-Joe O'Donnell"
Source: