diff --git a/lib/pp.rb b/lib/pp.rb index 40e83b2fe9..1ec5a880eb 100644 --- a/lib/pp.rb +++ b/lib/pp.rb @@ -286,16 +286,21 @@ class PP < PrettyPrint group(1, '{', '}') { seplist(obj, nil, :each_pair) {|k, v| group { - pp k - text '=>' - group(1) { - breakable '' - pp v - } + pp_hash_pair k, v } } } end + + # A pretty print for a pair of Hash + def pp_hash_pair(k, v) + pp k + text '=>' + group(1) { + breakable '' + pp v + } + end end include PPMethods diff --git a/test/test_pp.rb b/test/test_pp.rb index e51adde13e..2fdd5df114 100644 --- a/test/test_pp.rb +++ b/test/test_pp.rb @@ -247,25 +247,18 @@ end class PPInheritedTest < Test::Unit::TestCase class PPSymbolHash < PP - def pp_hash(obj) - group(1, "{", "}") { - seplist(obj, nil, :each_pair) {|k, v| - case k - when Symbol - text k.inspect.delete_prefix(":") - text ":" - sep = " " - else - pp k - text "=>" - sep = "" - end - group(1) { - breakable sep - pp v - } + def pp_hash_pair(k, v) + case k + when Symbol + text k.inspect.delete_prefix(":") + text ":" + group(1) { + breakable + pp v } - } + else + super + end end end