lib/translate.rb
# Parse the document retrieved from tree and add items into 
# the final results array.	
Parse the document retrieved from tree and add items into
the final results array.
Parse the document retrieved from tree and add items into the final results array .
def translate
			return nil unless valid?
			continue = false
			@items.clear
			klass = Language.respond_to?("klass_#{combination}") ? Language.send("klass_#{combination}") : "2"
			tree.search("table.Rtbl#{klass}/tr").each do |child|
				head = child.search("td.Head:first").first
				continue = !! (
					head.html =~ /Principal/ || 
					head.attributes['title'] =~ /Principal/ ||
					(head.html =~ /Additional/ and more) ||
					(head.attributes['title'] =~ /Additional/)) if head.respond_to?(:html)
				unless ! continue or child.classes =~ /(evenEx|oddEx)/
					description = child.search("td.FrCN#{klass}/*").to_s.sanitize
					translation = child.search("td.ToW#{klass}/*").to_s.sanitize
					@items << Item.new({ 
						:description 	=> description, 
						:translation 	=> translation,
						:new_line			=> ! child.search("td.FrW#{klass}").empty?
					}) unless description.empty? and translation.empty?
				end
			end
		end
def translate return nil unless valid? continue = false @items . clear klass = Language . respond_to? ( "klass_#{combination}" ) ? Language . send ( "klass_#{combination}" ) : "2" tree . search ( "table.Rtbl#{klass}/tr" ) . each do | child | head = child . search ( "td.Head:first" ) . first continue = ! ! ( head . html =~ / Principal / || head . attributes [ 'title' ] =~ / Principal / || ( head . html =~ / Additional / and more ) || ( head . attributes [ 'title' ] =~ / Additional / ) ) if head . respond_to? ( :html ) unless ! continue or child . classes =~ / (evenEx|oddEx) / description = child . search ( "td.FrCN#{klass}/*" ) . to_s . sanitize translation = child . search ( "td.ToW#{klass}/*" ) . to_s . sanitize @items << Item . new ( { :description => description , :translation => translation , :new_line => ! child . search ( "td.FrW#{klass}" ) . empty? } ) unless description . empty? and translation . empty? end end end
Parse the document retrieved from tree and add items into
the final results array.
Parse the document retrieved from tree and add items into the final results array .
# strip html tags