Skip to content

acook/introspection

Repository files navigation

Introspect

Tools for exploring Ruby's objects!

Basic Usage

require 'introspect/core_ext'  # the core extensions are OPTIONAL but handy
my_object.introspect

Tools Available

CONTENTS

Tells you all about the object and the objects inside it.

require 'introspect'
Introspect.introspect my_object, :contents

example

[1,2,3].introspect :contents

output

{
  [1, 2, 3]=>
    {
      :class=>Array,
        :ancestors=>
          [
            Array,
            Enumerable,
            Object,
            PP::ObjectMixin,
            Introspect,
            Kernel,
            BasicObject
          ]
    }
}

WHICH

Tells you which object a method is defined on.

require 'introspect'
Introspect.introspect my_object, :which, :method_name

example

[1,2,3].introspect :which, :cycle

output

Array

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/acook/introspection.

© Anthony M. Cook 2012-2016