Skip to content

Commit ebe2b26

Browse files
committed
Refactor Proc#inspect
1 parent 9d34580 commit ebe2b26

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/main/ruby/core/proc.rb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,14 @@ def f.binding
8686
end
8787

8888
def to_s
89-
sl = source_location
90-
return super if sl.nil?
91-
file, line = sl
92-
93-
l = ' (lambda)' if lambda?
94-
if file and line
95-
"#<#{self.class}:0x#{self.object_id.to_s(16)}@#{file}:#{line}#{l}>".force_encoding('ASCII-8BIT')
96-
else
97-
"#<#{self.class}:0x#{self.object_id.to_s(16)}#{l}>".force_encoding('ASCII-8BIT')
98-
end
99-
end
89+
base = super()
90+
file, line = source_location
10091

92+
suffix = "".b
93+
suffix << "@#{file}:#{line}" if file and line
94+
suffix << ' (lambda)' if lambda?
95+
base.b.insert -2, suffix
96+
end
10197
alias_method :inspect, :to_s
10298

10399
def to_proc

0 commit comments

Comments
 (0)