Module: PP::PPMethods

Defined in:
lib/ver/vendor/better_pp_hash.rb

Instance Method Summary collapse

Instance Method Details

#pp_hash(obj) ⇒ Object

make hashes prettier



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ver/vendor/better_pp_hash.rb', line 6

def pp_hash(obj)
  group(1, '{', '}') do
    seplist(obj, nil, :each_pair) do |k, v|
      group do
        if k.is_a?(Symbol) && k =~ /^\w+$/
          text k.to_s
          text ': '
        else
          pp k
          text ' => '
        end

        group(1) do
          breakable ''
          pp v
        end
      end
    end
  end
end