-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unit_separator
to #humanize
and #humanize_bytes
#15176
base: master
Are you sure you want to change the base?
Conversation
separate_unit
for humanize
and humanize_bytes
separate_unit
for humanize
and humanize_bytes
Maybe a configurable parameter could be better than a boolean flag? |
Does it make sense to give the user full control over the separator, or should we define an enum that limits options? |
Also, the default IMO should use a regular space for compatibility. |
What would be the reason for limiting? I don't see why any arbitrary restriction would be useful. If someone want's a particular string as separator, let them have it. |
Just pushed the change to allow for custom unit separators. Thought about a Char but that felt overly restrictive as well. 👍 |
separate_unit
for humanize
and humanize_bytes
unit_separator
to #humanize
and #humanize_bytes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a tiny nitpick: specs could use a Char
whenever possible to demonstrate the encouraged use, use a String when there are more than one char, and just leave one check that we can pass a 1 char string (or nil, number or whatever).
Good call. I cleaned up the tests and left the ones that I think are meaningful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your patience while we ironed out this feature 🙇
Happy to! Honored to contribute. 🔮✨ |
Adds a
separate_unit
parameter to thehumanize
andhumanize_bytes
methods. If selected adds a non-breaking space ('\u00A0'
) between the value and the unit.Also includes relevant specs.
Fixes #14349