humbargs
11/27/2013 - 8:59 PM

Ruby: Metaprogramming

Ruby: Metaprogramming

# Get the class type
my_obj.class

# get the instance methods of a class
# false indicates that inherited method should not be included
my_obj.class.instance_methods(false)

# get instance variables
# In ruby, instance variables aren't tied to a class like in java.
# They only spring into existence when they are assigned.
my_obj.instance_variables