summaryrefslogtreecommitdiffstats
path: root/lib/prettyprint.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-02-05 14:59:46 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-02-05 14:59:46 +0000
commit7d3aefe31df231fc0d8a5f9c33da0c83b28e1efd (patch)
tree499504866761bfcca6c3851493d8d345702aeecb /lib/prettyprint.rb
parentd823b0b00e4b643b3bd7a14e87490d8a4f96fb86 (diff)
downloadruby-7d3aefe31df231fc0d8a5f9c33da0c83b28e1efd.tar.gz
ruby-7d3aefe31df231fc0d8a5f9c33da0c83b28e1efd.tar.xz
ruby-7d3aefe31df231fc0d8a5f9c33da0c83b28e1efd.zip
* lib/prettyprint.rb (PrettyPrint#seplist): added.
* lib/pp.rb (PPMethods#pp_object): use seplist. (PPMethods#pp_hash): ditto. (Array#pretty_print): ditto. (Struct#pretty_print): ditto. (MatchData#pretty_print): ditto. * lib/set.rb (Set#pretty_print): use seplist. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@5623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/prettyprint.rb')
-rw-r--r--lib/prettyprint.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/prettyprint.rb b/lib/prettyprint.rb
index 70b6da792..6f2c8ea7c 100644
--- a/lib/prettyprint.rb
+++ b/lib/prettyprint.rb
@@ -159,6 +159,19 @@ class PrettyPrint
@group_stack.last
end
+ def seplist(list, sep=nil, iter_method=:each)
+ sep ||= lambda { comma_breakable }
+ first = true
+ list.__send__(iter_method) {|*v|
+ if first
+ first = false
+ else
+ sep.call
+ end
+ yield(*v)
+ }
+ end
+
def first?
current_group.first?
end