>>>>> "w" == walter  <walter / mwsewall.com> writes:

 Try this


   class MyHash < Hash
      def default(k)
         self[k] = 0
      end
   end

w> module ShipToCleanUp
w>   def notes
w>     results = []
w>     1.upto(6) do |i|
w>       results << send("note#{i}")
w>     end
w>     results.join(" ").strip
w>   end
  
w>   def word_counts
w>     results = Hash.new{|h,k| h[k] = 0}

       results = MyHash.new

w>     notes.split(/\s+/).each{|word| results[word]+=1}
w>     results
w>   end
w> end


w> if __FILE__ == $0
w>   require 'test/unit'
w>   class ShipToCleanUpTester < Test::Unit::TestCase
w>     class ShipTo
w>       include ShipToCleanUp
w>       attr_accessor :note1, :note2, :note3, :note4, :note5, :note6
w>       def initialize(n1='', n2='', n3='', n4='', n5='', n6='')
w>         @note1, @note2, @note3, @note4, @note5, @note6 = n1, n2, n3, 
w> n4, n5, n6
w>       end
w>     end
    
w>     def setup
w>       @shipTo1 = ShipTo.new('LINE 1 AND SOME MORE ON LINE 1 ', '      
w> ***** LINE 2 *****     ', '', '', 'LINE 5   ', 'AND LINE 6')
w>     end

w>     def test_word_counts
w>       expected = Hash.new{|h,k| h[k] = 0}

         expected = MyHash.new

w>       expected['LINE'] = 5



Guy Decoux