This post originated from an RSS feed registered with Ruby Buzz
by Obie Fernandez.
Original Post: Pause execution using gets
Feed Title: Obie On Rails (Has It Been 9 Years Already?)
Feed URL: http://jroller.com/obie/feed/entries/rss
Feed Description: Obie Fernandez talks about life as a technologist, mostly as ramblings about software development and consulting. Nowadays it's pretty much all about Ruby and Ruby on Rails.
Quick Tip: Ruby's humble gets method pauses execution to get input from the command line which makes it useful in debugging scenarios, especially when debugging loops or output from remote servers. Try using gets as a quick and easy way to pause execution while you examine some debugging content that you've output to the console with puts.
I used this technique last night to try and figure out why one of my flickr scripts was occasionally failing. It looked something like this (code sample altered and stripped down significantly for clarity's sake):