* 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
This commit is contained in:
parent
ccec5b49ca
commit
627c179a99
@ -1,3 +1,8 @@
|
|||||||
|
Tue Oct 11 06:09:52 2011 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
|
* lib/pp.rb: Move PP documentation to top of class PP. Patch by
|
||||||
|
Sylvain Daubert. [Ruby 1.9 - Bug #5430]
|
||||||
|
|
||||||
Tue Oct 11 06:06:29 2011 Eric Hodel <drbrain@segment7.net>
|
Tue Oct 11 06:06:29 2011 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
* ext/coverage/coverage.c (Init_coverage): Change list format and
|
* ext/coverage/coverage.c (Init_coverage): Change list format and
|
||||||
|
43
lib/pp.rb
43
lib/pp.rb
@ -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.
|
# == Pretty-printer for Ruby objects.
|
||||||
#
|
#
|
||||||
# = Which seems better?
|
# = Which seems better?
|
||||||
@ -42,28 +63,6 @@
|
|||||||
#
|
#
|
||||||
# = Author
|
# = Author
|
||||||
# Tanaka Akira <akr@m17n.org>
|
# 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
|
class PP < PrettyPrint
|
||||||
# Outputs +obj+ to +out+ in pretty printed format of
|
# Outputs +obj+ to +out+ in pretty printed format of
|
||||||
# +width+ columns in width.
|
# +width+ columns in width.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user