如何在撬中留下一个方法

时间:2014-11-13 16:22:23

标签: ruby-on-rails ruby pry

我在某些Ruby代码中使用binding.pry,但我无法弄清楚如何摆脱我不想参与的长方法。

我知道n代表下一行,c代表继续,但我无法摆脱某种方法。我不想退出,我只是想摆脱当前的方法。

2 个答案:

答案 0 :(得分:3)

方便的是,pry有一个名为“help”的命令。一旦发布,它列出了许多可以做的事情,包括:

  break              Set or edit a breakpoint.
  breakpoints        List defined breakpoints.
  continue           Continue program execution and end the pry session.
  finish             Execute until current stack frame returns.
  next               Execute the next line within the current stack frame.
  step               Step execution into the next line or method.

它还支持其他命令的别名,这很方便:

  !!!                Alias for `exit-program`
  !!@                Alias for `exit-all`
  $                  Alias for `show-source`
  ?                  Alias for `show-doc`
  @                  Alias for `whereami`
  breakpoint         Alias for `break`
  breaks             Alias for `breakpoints`
  c                  Alias for `continue`
  clipit             Alias for `gist --clip`
  f                  Alias for `finish`
  file-mode          Alias for `shell-mode`
  history            Alias for `hist`
  n                  Alias for `next`
  quit               Alias for `exit`
  quit-program       Alias for `exit-program`
  reload-method      Alias for `reload-code`
  s                  Alias for `step`
  show-method        Alias for `show-source`

答案 1 :(得分:2)

根据documentation您要查找的命令是f

  

完成:执行直到当前堆栈帧返回。

shortcuts

if defined?(PryDebugger)
  Pry.commands.alias_command 'c', 'continue'
  Pry.commands.alias_command 's', 'step'
  Pry.commands.alias_command 'n', 'next'
  Pry.commands.alias_command 'f', 'finish'
end