Move common inspect code up to Node

This commit is contained in:
Michael Miller 2021-05-08 13:22:13 -06:00
parent d292c01e74
commit 88b323bc27
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD
2 changed files with 16 additions and 11 deletions

View file

@ -160,17 +160,8 @@ module Spectator
# Exposes information about the example useful for debugging.
def inspect(io)
# Full example name.
io << '"'
to_s(io)
io << '"'
# Add location if it's available.
if (location = self.location)
io << " @ "
io << location
end
super
io << ' '
io << result
end

View file

@ -51,5 +51,19 @@ module Spectator
def to_s(io)
(@name || "<anonymous>").to_s(io)
end
# Exposes information about the node useful for debugging.
def inspect(io)
# Full node name.
io << '"'
to_s(io)
io << '"'
# Add location if it's available.
if (location = self.location)
io << " @ "
io << location
end
end
end
end