Skip to content

Instantly share code, notes, and snippets.

@bhelx
Created January 26, 2012 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhelx/1681396 to your computer and use it in GitHub Desktop.
Save bhelx/1681396 to your computer and use it in GitHub Desktop.
Pry trick
require 'pry'
class Object
LABELS = [:label1, :label2]
def breakpt(label, target=self)
LABELS.include?(label) ? Pry.start(target) : nil
end
end
class Greeter
def initialize
@age = 42
@name = "Hello World!"
end
def greet
binding.breakpt(:ignored_label)
puts "Hello #{@name}"
binding.breakpt(:label1)
puts "Age #{@age}"
end
end
g = Greeter.new
g.greet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment