Skip to content

Ruby Debug Cheat Sheet

TheNotary edited this page Feb 23, 2016 · 5 revisions

####References

####Cheat Codes

  • Place a breakpoint somewhere in your code
    • binding.pry
  • Print Call Stack
    • caller
  • Find the class of an object
    • 1.class # => Fixnum
  • See what a class inherits from
    • Fixnum.superclass # => Integer
  • Find definition of a method on an object say 1
    • 1.method(:to_s).source_location
  • Print all interesting methods on a class
    • (Fixnum.public_instance_methods - Object.public_instance_methods).sort
  • Print all interesting methods on an object
    • (my_object.public_methods - Object.public_instance_methods).sort

Clone this wiki locally