Skip to content

Instantly share code, notes, and snippets.

@bhelx

bhelx/pry_trick.rb

Created Jan 26, 2012
Embed
What would you like to do?
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