# PP::PPMethods (Module)

In: | pp.rb

## Methods

comma_breakable guard_inspect_key object_address_group object_group pp pp_hash pp_object

## Constants

InspectKey | = | :__inspect_key__

## Public Instance methods

guard_inspect_key() {|| ...}

[Source]

    # File pp.rb, line 160
        def guard_inspect_key
          if Thread.current[InspectKey] == nil
            Thread.current[InspectKey] = []
          end

          save = Thread.current[InspectKey]

          begin
            Thread.current[InspectKey] = []
            yield
          ensure
            Thread.current[InspectKey] = save
          end
        end

pp(obj)

[Source]

    # File pp.rb, line 175
        def pp(obj)
          id = obj.__id__

          if Thread.current[InspectKey].include? id
            group {obj.pretty_print_cycle self}
            return
          end

          begin
            Thread.current[InspectKey] << id
            group {obj.pretty_print self}
          ensure
            Thread.current[InspectKey].pop unless PP.sharing_detection
          end
        end

object_group(obj, &block)

[Source]

    # File pp.rb, line 191
        def object_group(obj, &block)
          group(1, '#<' + obj.class.name, '>', &block)
        end

object_address_group(obj, &block)

[Source]

    # File pp.rb, line 195
        def object_address_group(obj, &block)
          group(1, sprintf('#<%s:0x%x', obj.class.to_s, obj.__id__ * 2), '>', &block)
        end

comma_breakable()

[Source]

    # File pp.rb, line 199
        def comma_breakable
          text ','
          breakable
        end

pp_object(obj)

[Source]

    # File pp.rb, line 204
        def pp_object(obj)
          object_address_group(obj) {
            obj.pretty_print_instance_variables.each {|v|
              v = v.to_s if Symbol === v
              text ',' unless first?
              breakable
              text v
              text '='
              group(1) {
                breakable ''
                pp(obj.instance_eval(v))
              }
            }
          }
        end

pp_hash(obj)

[Source]

    # File pp.rb, line 220
        def pp_hash(obj)
          group(1, '{', '}') {
            obj.each {|k, v|
              comma_breakable unless first?
              group {
                pp k
                text '=>'
                group(1) {
                  breakable ''
                  pp v
                }
              }
            }
          }
        end

[Validate]