diff options
author | Nobuyoshi Nakada <[email protected]> | 2021-09-05 22:19:48 +0900 |
---|---|---|
committer | git <[email protected]> | 2024-02-21 16:45:01 +0000 |
commit | 6e704311bbb7c499f191d9b7d29dac0e37feabde () | |
tree | 61dfaf7b53a44cdfed2e12ad876fbd36cb934d3e | |
parent | 37b8fc7477b1cbeb4f3a21ad4b22971170709cfa (diff) |
[ruby/pp] Extract pp_hash_pair
The method which prints single pair of a hash, to make extending pretty printing Hash easier, apart from Hash construct itself. https://.com/ruby/pp/commit/3fcf2d1142
-rw-r--r-- | lib/pp.rb | 17 | ||||
-rw-r--r-- | test/test_pp.rb | 29 |
2 files changed, 22 insertions, 24 deletions
@@ -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 - } } } } end end include PPMethods @@ -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 - } } - } end end |