Typing long-winded scripts into the irb prompt can be a pain in the ass! It's been annoying me for a while now, so I decided enough was enough.
I found a way to run a ruby script (the one which is currently open in vim) through irb, then leave you at a irb prompt to execute further commands.
Say you're editing a ruby script in vim...
In vim you can run external commands by using ":!". Also you can use "%" to specify the current file. So with this in mind you can run the above script through irb and use the -r argument to leave you at the irb prompt. Here is what you need to type in vim:
This will leave you at an irb prompt where you can perform actions on "Book"...
Then when you're finished, exiting the irb prompt will bring you back to the file you were editing :)
Also, to make your life even easier, you can use a short-hand vim command to execute the last command. This saves you from typing ":! irb -r %" everytime...
This has made my life so much easier when testing a piece of code in isolation.
UPDATE: A few people have pointed out the interactive_editor gem. Both methods work, choose whichever suits you best.