diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-10 21:10:02 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-10-10 21:10:02 +0000 |
commit | 627c179a99856b6aab653586849145eec3c7b8e6 (patch) | |
tree | 0fad0fa2b903111d50a8115d5a237d528bf1fc76 /lib/pp.rb | |
parent | ccec5b49ca8dee413c0e6cd205c21b44eb30c015 (diff) |
* lib/pp.rb: Move PP documentation to top of class PP. Patch by
Sylvain Daubert. [Ruby 1.9 - Bug #5430]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/pp.rb')
-rw-r--r-- | lib/pp.rb | 43 |
1 files changed, 21 insertions, 22 deletions
@@ -1,3 +1,24 @@ +require 'prettyprint' + +module Kernel + # returns a pretty printed object as a string. + def pretty_inspect + PP.pp(self, '') + end + + private + # prints arguments in pretty form. + # + # pp returns argument(s). + def pp(*objs) # :doc: + objs.each {|obj| + PP.pp(obj) + } + objs.size <= 1 ? objs.first : objs + end + module_function :pp +end + # == Pretty-printer for Ruby objects. # # = Which seems better? @@ -42,28 +63,6 @@ # # = Author # Tanaka Akira <akr@m17n.org> - -require 'prettyprint' - -module Kernel - # returns a pretty printed object as a string. - def pretty_inspect - PP.pp(self, '') - end - - private - # prints arguments in pretty form. - # - # pp returns argument(s). - def pp(*objs) # :doc: - objs.each {|obj| - PP.pp(obj) - } - objs.size <= 1 ? objs.first : objs - end - module_function :pp -end - class PP < PrettyPrint # Outputs +obj+ to +out+ in pretty printed format of # +width+ columns in width. |