Skip to content

Instantly share code, notes, and snippets.

@sas1ni69
Created November 1, 2018 08:34
Show Gist options
  • Save sas1ni69/c904adc595c117d5e4199df63ab0c484 to your computer and use it in GitHub Desktop.
Save sas1ni69/c904adc595c117d5e4199df63ab0c484 to your computer and use it in GitHub Desktop.
def format_name(format: "%{first_name} %{last_name}, (%{preferred_name})", **names)
defaults = { first_name: '', last_name: '', preferred_name: '' }
names = defaults.merge(names.slice(:first_name, :last_name, :preferred_name))
(format % names).squish
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment