Class: CSVFormatter

Inherits:
BaseFormatter show all
Defined in:
lib/teuton/report/formatter/csv_formatter.rb

Instance Method Summary collapse

Methods inherited from BaseFormatter

#deinit, #init, #initialize, #trim, #w

Constructor Details

This class inherits a constructor from BaseFormatter

Instance Method Details

#processObject



4
5
6
7
8
9
10
# File 'lib/teuton/report/formatter/csv_formatter.rb', line 4

def process
	d = ";"
	@head.each { |key, value| w "HEAD#{d}#{key}#{d}#{value}\n" }
	@datagroups.each { |item| process_datagroup(item,d) }
	@tail.each { |key, value| w "TAIL#{d}#{key}#{d}#{value}\n" }
	deinit
end

#process_datagroup(group, delimiter = ";") ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/teuton/report/formatter/csv_formatter.rb', line 12

def process_datagroup(group, delimiter = ";")
	d = delimiter
	a = "DATAGROUP#{group.order}#{d}"
	group.head.each { |key, value| w "#{a}HEAD#{d}#{key}#{d}#{value}\n" }
	group.lines.each do |i|
		if i.instance_of? Hash
			w "#{a}LINES#{d}ACTION#{d}#{i[:id]}#{d}#{i[:weight]}#{d}#{i[:description]}\n"
		else
       w "#{a}LINES#{d}LOG#{d}#{i}\n"
		end
	end
	group.tail.each { |key, value| w "#{a}TAIL#{d}#{key}#{d}#{value}\n" }
end