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 | 0c792a32b7e600320eb5eb3fd9e3ae1fe57e8b58 (patch) | |
tree | 499504866761bfcca6c3851493d8d345702aeecb /lib/prettyprint.rb | |
parent | 90d8cbb1ee3c7955642e1af995361eb0d9558aa9 (diff) | |
download | ruby-0c792a32b7e600320eb5eb3fd9e3ae1fe57e8b58.tar.gz |
* 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/trunk@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 |