Skip to content

Instantly share code, notes, and snippets.

@banister
Created July 31, 2012 20:57
Show Gist options
  • Save banister/3220467 to your computer and use it in GitHub Desktop.
Save banister/3220467 to your computer and use it in GitHub Desktop.
my_pilot = PryAutopilot.new do
on ->(frame) { frame.eval("@i == x") } do
puts "fizz (@i == x) x is #{frame.var("x")}"
end
on ->(frame) { frame.eval("@i == y") } do
puts "buzz (@i == y) y is #{frame.var("y")}"
end
on ->(frame) { frame.eval("@i == (y + x)") } do
puts "fizzbuzz (@i == (x + y)), (x + y) is #{frame.eval("x+y")}"
run "exit-all"
end
on ->(frame) { true } do
run "step"
end
end
Pry.config.input = my_pilot
def fizzbuzz(x, y)
binding.pry
@i = 0
1.upto(100) { |i| @i = i }
end
fizzbuzz(3, 5)
fizz (@i == x) x is 3
buzz (@i == y) y is 5
fizzbuzz (@i == (x + y)), (x + y) is 8
@jasonLaster
Copy link

  on ->(frame) { @i == y + x) } do
    frame.exec {puts "fizzbuzz (@i == (x + y)), (x + y) is #{x+y}"}    
    run "exit-all"
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment