268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
|
# File 'lib/colorful_inspect.rb', line 268
def pretty_print(q)
if /\(Kernel\)#/ !~ Object.instance_method(:method).bind(self).call(:inspect).inspect
q.text self.inspect
elsif /\(Kernel\)#/ !~ Object.instance_method(:method).bind(self).call(:to_s).inspect &&
instance_variables.empty?
q.text self.to_s
else
id = "%x" % (__id__ * 2)
id.sub!(/\Af(?=[[:xdigit:]]{2}+\z)/, '') if id.sub!(/\A\.\./, '')
klass = ColorfulInspect.colorize(q, :class, self.class.to_s)
q.group(ColorfulInspect.indent, "\#<#{klass}:0x#{id}", '>') do
q.seplist(pretty_print_instance_variables, lambda { q.text ',' }) do |ivar|
q.breakable
q.text ColorfulInspect.colorize(q, :ivar, ivar.to_s)
q.text '='
q.group(ColorfulInspect.indent) do
q.breakable ''
q.pp instance_variable_get(ivar)
end
end
end
end
end
|