A default pretty printing method for general objects. It calls pretty_print_instance_variables to list instance variables.
If self
has a customized (redefined) inspect method, the
result of self.inspect is used but it obviously has no line break hints.
This module provides predefined pretty_print methods for some of the most commonly used built-in classes for convenience.
# File lib/pp.rb, line 279 def pretty_print(q) method_method = Object.instance_method(:method).bind(self) begin inspect_method = method_method.call(:inspect) rescue NameError end if inspect_method && /\(Kernel\)#/ !~ inspect_method.inspect q.text self.inspect elsif !inspect_method && self.respond_to?(:inspect) q.text self.inspect else q.pp_object(self) end end
A default pretty printing method for general objects that are detected as part of a cycle.
Is inspect implementation using pretty_print. If you implement pretty_print, it can be used as follows.
alias inspect pretty_print_inspect
However, doing this requires that every class that inspect is called on implement pretty_print, or a RuntimeError will be raised.
Returns a sorted array of instance variable names.
This method should return an array of names of instance variables as symbols or strings as: +[:@a, :@b]+.