Left pad Node#inspect hex digits with zeros. #54
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This tries to adjust
Node
#inspect to more closely resemble the vanilla format by adding left padded zeros. I don't know if less padding would be preferred, but it seems nice to left pad a bit so printed hierarchies align and such. Maybe eight hex digits?For comparison, this is before.
And after.
Or with 8 rather than 16 for padding.
Or even just 6.
I also added a left shift of the object ID, like has been done with inspect in recent Rubies, but I'm unsure if that's still worth doing now that Ruby 2.7 is doing IDs differently.
Ruby 2.6:
Ruby 2.7
I don't know if you want to left pad or left shift but I got to making the PR before I realized object IDs changed in Ruby 2.7. Are sixteen hex digits too many to pad? I personally prefer padding 8 to avoid the varied length.
Thanks for the great library in any case!