The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Pause execution using gets

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Obie Fernandez

Posts: 608
Nickname: obie
Registered: Aug, 2005

Obie Fernandez is a Technologist for ThoughtWorks
Pause execution using gets Posted: Mar 4, 2007 2:16 PM
Reply to this message Reply

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.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Obie Fernandez
Latest Posts From Obie On Rails (Has It Been 9 Years Already?)

Advertisement

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):

def self.photos_search(options)
  rs = request('photos.search', options)
  (rs['photos']['photo'] || {}).each do |record|
    begin
      FlickrPhoto.create!(record)
    rescue Exception => err
      puts err
      puts record.inspect
      gets
      next
    end
  end
end

Read: Pause execution using gets

Topic: locate and spotlight Previous Topic   Next Topic Topic: Review: The Ruby Way

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use