Prying Ruby

Hi, I'm Tyok

About Pry

Pry is a replacement for irb

Pry is an exploration tool

Pry is a debugging tool

Starting Pry

  1. Install it:

    gem install pry

    Install doc. package:

    gem install pry-doc

    * Use sudo if that's how you roll.

  2. Run it

    pry
  3. I WANNA PLAY A GAME

    [1] pry(main)>_

Some Cool Stuff

Try These On Your Pry Console

show a method's doc

show-doc {}.length

show a method's code

show-method {}.sum

Get help

help

Suppress output

a = (1..1000).to_a;

Using Rails?

Use pry-rails!

Bundle the gems first

gem "pry-rails"
gem "pry-code"

Do not forget to:

bundle install

Rails console is now using pry!

rails c

Debug Your App!

Put this line where you want to inspect things:

binding.pry

Forgot where you were?

whereami

There's more...

Want some REAL debugger?

gem "pry-nav"

Use the binding.pry as your debugging start point.

step
next
continue

There's A Whole Lot More

But That's All For Today :P

More on Pry

/