Hi there, i'm looking at my below code. It doesn't seem pretty at all. I
am sure there must be a better way to achieve the same functionality.

Could anyone please provide some pointers as to how I could refactor?


cards = results.root.elements

pngmaker = PngMaker.new(100,100)

cards.each{ |card|
  card = Card.new(card)
  next if (card.drawing).to_s.empty?

  found_tif = Dir.glob(File.join(@search_path, '**',
"#{card.drawing}#{TIF}"), File::FNM_CASEFOLD).first

  if (!found_tif)
    puts "#{card.number} couldn't find #{card.drawing}#{TIF} in:
#{@search_path}"
    next
  end

  new_png = pngmaker.make_png_copy_of(found_tif)
  if (!new_png)
    puts "#{card.number} couldn't make png copy of: #{found_tif}"
    next
  end

  if (!card.attach_to_card_descrip(card.number, new_png))
    puts "#{card.number} couldn't attach: #{new_png}"
    next
  end
}

-- 
Posted via http://www.ruby-forum.com/.