On Tue, 30 Jun 2009, David A. Black wrote:

> Hi --
>
> On Tue, 30 Jun 2009, Diana Jaunzeikare wrote:
>
>> Thanks a lot! It worked like a charm!
>
> Rob Biedenharn, in another context, reminded me that
> exception-handling blocks can have an "else" clause. So you could do
> the slightly simpler:
>
>  begin
>    require "xml"
>  rescue LoadError
>    puts "No xml library..."
>  else
>    class TestPhyloXML1 < Test::Unit::TestCase
>      ...
>    end
>  end

OK, third time a charm.

   begin
     require 'xml'
     class TestPhyloXML1 < Test::Unit::TestCase
       ...
     end
   rescue LoadError
     puts "No xml library..."
   end

I think that's as compact and streamlined as I can get it :-)


David

-- 
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Now available: The Well-Grounded Rubyist (http://manning.com/black2)
"Ruby 1.9: What You Need To Know" Envycasts with David A. Black
http://www.envycasts.com