diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-02-05 14:59:46 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-02-05 14:59:46 +0000 |
commit | 9f45dc126cc461b78984383f4c15bfdc80b1f6d5 (patch) | |
tree | 7e25fe244595c7850d5bf03a30ee5520e76eddae /lib/prettyprint.rb | |
parent | c3c6d7cbca3ec28f2f9133f2fd1d5c158c8a0929 (diff) |
* 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: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@5623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/prettyprint.rb')
-rw-r--r-- | lib/prettyprint.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/prettyprint.rb b/lib/prettyprint.rb index 70b6da7924..6f2c8ea7cc 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 |