Tools for exploring Ruby's objects!
require 'introspect/core_ext' # the core extensions are OPTIONAL but handy
my_object.introspect
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
]
}
}
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
Bug reports and pull requests are welcome on GitHub at https://github.com/acook/introspection.
© Anthony M. Cook 2012-2016