-
-
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
Unify #inspect output formatting in several places #5858
Conversation
77748cc
to
dbb630d
Compare
src/time/location.cr
Outdated
@@ -61,11 +61,11 @@ class Time::Location | |||
end | |||
|
|||
def inspect(io : IO) | |||
io << "Time::Zone<" | |||
io << "Time::Zone(" | |||
io << offset | |||
io << ", " << name |
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.
Since we are here, they can be merged to io << "Time::Zone" << offset << ", " << name
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.
@j8r I don't think that would be an improvement.
src/time/location.cr
Outdated
@@ -74,12 +74,12 @@ class Time::Location | |||
getter? standard, utc | |||
|
|||
def inspect(io : IO) | |||
io << "Time::ZoneTransition<" | |||
io << "Time::ZoneTransition(" | |||
io << '#' << index << ", " |
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.
Ditto
src/regex/match_data.cr
Outdated
size.times do |i| | ||
io << " " | ||
io << " " if i > 0 |
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.
I think the space string can be replaced by a char ' '
src/file/stat.cr
Outdated
io << "#<File::Stat" | ||
io << " dev=0x" | ||
io << "File::Stat(" | ||
io << "dev=0x" |
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.
Can be merged to io << "File::Stat(dev=0x"
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.
IMHO that just looks weird, especially since there are lines below having such format.
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.
Why weird? Aesthetics? I don't see why these strings should not be combined.
src/regex/match_data.cr
Outdated
io << name_table.fetch(i, i) << ":" if i > 0 | ||
self[i]?.inspect(io) | ||
end | ||
io << ">" | ||
io << ")" |
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.
Ditto, can be a char
src/regex/match_data.cr
Outdated
size.times do |i| | ||
io << " " | ||
io << " " if i > 0 | ||
io << name_table.fetch(i, i) << ":" if i > 0 |
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.
":"
=> ':'
dbb630d
to
6145459
Compare
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 few details to improve implementation, but otherwise looks good.
src/file/stat.cr
Outdated
io << "#<File::Stat" | ||
io << " dev=0x" | ||
io << "File::Stat(" | ||
io << "dev=0x" |
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.
Why weird? Aesthetics? I don't see why these strings should not be combined.
src/regex/match_data.cr
Outdated
size.times do |i| | ||
io << ' ' | ||
io << ' ' if i > 0 |
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.
Could be combined with the following line to avoid i > 0
twice.
size.times do |i| | ||
pp.breakable | ||
pp.breakable if i > 0 |
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.
Put this line in the else
branch to avoid comparing twice.
src/time/location.cr
Outdated
@@ -61,11 +61,11 @@ class Time::Location | |||
end | |||
|
|||
def inspect(io : IO) | |||
io << "Time::Zone<" | |||
io << "Time::Zone(" | |||
io << offset | |||
io << ", " << name |
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.
@j8r I don't think that would be an improvement.
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.
Nice! But needs a rebase...
Reference#inspect: `#<Type …>` Struct#inspect: `Type(…)`
6145459
to
601bba0
Compare
@asterite rebased. |
Is it really only regex match data? cool |
Reference#inspect: `#<Type …>` Struct#inspect: `Type(…)`
Reference:
#<Type …>
Struct:
Type(…)