Sha256: 192a5778014045fb9aae626131f4e5a4bb5135f5b688125d341452493c738e77

Contents?: true

Size: 501 Bytes

Versions: 2

Compression:

Stored size: 501 Bytes

Contents

require 'pp'

class PP
  module PPMethods
    # make hashes prettier
    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ver-2010.08 lib/ver/vendor/better_pp_hash.rb
ver-2010.02 lib/ver/vendor/better_pp_hash.rb