From f3d95cce97237eff6ef8248e29e0c40062c72d44 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 14 Sep 2008 15:18:53 +0000 Subject: trailing spaces removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/pp.rb | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'lib/pp.rb') diff --git a/lib/pp.rb b/lib/pp.rb index ec896b3ce5..41f51b0046 100644 --- a/lib/pp.rb +++ b/lib/pp.rb @@ -1,10 +1,10 @@ # == Pretty-printer for Ruby objects. -# +# # = Which seems better? -# +# # non-pretty-printed output by #p is: # #, @group_queue=#], []]>, @buffer=[], @newline="\n", @group_stack=[#], @buffer_width=0, @indent=0, @maxwidth=79, @output_width=2, @output=#> -# +# # pretty-printed output by #pp is: # #, # @output_width=2> -# +# # I like the latter. If you do too, this library is for you. -# +# # = Usage -# +# # pp(obj) # # output +obj+ to +$>+ in pretty printed format. -# +# # It returns +nil+. -# +# # = Output Customization # To define your customized pretty printing function for your classes, # redefine a method #pretty_print(+pp+) in the class. @@ -67,10 +67,10 @@ end class PP < PrettyPrint # Outputs +obj+ to +out+ in pretty printed format of # +width+ columns in width. - # + # # If +out+ is omitted, +$>+ is assumed. # If +width+ is omitted, 79 is assumed. - # + # # PP.pp returns +out+. def PP.pp(obj, out=$>, width=79) q = PP.new(out, width) @@ -82,7 +82,7 @@ class PP < PrettyPrint # Outputs +obj+ to +out+ like PP.pp but with no indent and # newline. - # + # # PP.singleline_pp returns +out+. def PP.singleline_pp(obj, out=$>) q = SingleLine.new(out) @@ -138,12 +138,12 @@ class PP < PrettyPrint # Adds +obj+ to the pretty printing buffer # using Object#pretty_print or Object#pretty_print_cycle. - # + # # Object#pretty_print_cycle is used when +obj+ is already # printed, a.k.a the object reference chain has a cycle. def pp(obj) id = obj.object_id - + if check_inspect_key(id) group {obj.pretty_print_cycle self} return @@ -158,7 +158,7 @@ class PP < PrettyPrint end # A convenience method which is same as follows: - # + # # group(1, '#<' + obj.class.name, '>') { ... } def object_group(obj, &block) # :yield: group(1, '#<' + obj.class.name, '>', &block) @@ -185,7 +185,7 @@ class PP < PrettyPrint end # A convenience method which is same as follows: - # + # # text ',' # breakable def comma_breakable @@ -195,23 +195,23 @@ class PP < PrettyPrint # Adds a separated list. # The list is separated by comma with breakable space, by default. - # + # # #seplist iterates the +list+ using +iter_method+. # It yields each object to the block given for #seplist. # The procedure +separator_proc+ is called between each yields. - # + # # If the iteration is zero times, +separator_proc+ is not called at all. - # + # # If +separator_proc+ is nil or not given, # +lambda { comma_breakable }+ is used. # If +iter_method+ is not given, :each is used. - # + # # For example, following 3 code fragments has similar effect. - # + # # q.seplist([1,2,3]) {|v| xxx v } - # + # # q.seplist([1,2,3], lambda { q.comma_breakable }, :each) {|v| xxx v } - # + # # xxx 1 # q.comma_breakable # xxx 2 @@ -275,11 +275,11 @@ class PP < PrettyPrint # 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. def pretty_print(q) @@ -302,7 +302,7 @@ class PP < PrettyPrint end # 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]+. def pretty_print_instance_variables @@ -311,7 +311,7 @@ class PP < PrettyPrint # 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 @@ -629,7 +629,7 @@ if __FILE__ == $0 result = PP.pp(a, '') assert_equal("#{a.inspect}\n", result) end - + def test_to_s_without_iv a = Object.new def a.to_s() "aaa" end -- cgit v1.2.3