Skip to content

Instantly share code, notes, and snippets.

@cowboy-cod3r
Created November 27, 2013 20:59
Show Gist options
  • Save cowboy-cod3r/7683108 to your computer and use it in GitHub Desktop.
Save cowboy-cod3r/7683108 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment