Although I'm not sure exactly why you want to collect all text nodes (perhaps there is a more efficient solution), this should get you started:
require 'nokogiri'
doc = Nokogiri::HTML(open('doc'))
doc.at_css("body").traverse do |node|
puts "***#{node.name}"
puts node.text
end
It uses Nokogiri's traverse
which will visit all nodes under your starting node.