1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
akr 2004-02-05 14:59:46 +00:00
parent 90d8cbb1ee
commit 0c792a32b7
4 changed files with 32 additions and 19 deletions

View file

@ -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