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, #trim, #w

Constructor Details

#initialize(report) ⇒ CSVFormatter

Returns a new instance of CSVFormatter.



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

def initialize(report)
  super(report)
end

Instance Method Details

#process ⇒ Object



9
10
11
12
13
14
15
# File 'lib/teuton/report/formatter/csv_formatter.rb', line 9

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(pGroup, delimiter = ';') ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/teuton/report/formatter/csv_formatter.rb', line 17

def process_datagroup(pGroup, delimiter=';')
  d = delimiter
  a = "DATAGROUP"+pGroup.order.to_s+d
  pGroup.head.each { |key,value| w a+"HEAD"+d+key.to_s+d+value.to_s+"\n" }
  pGroup.lines.each do |i|
    if i.class.to_s=='Hash' then
      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
  pGroup.tail.each { |key,value| w a+"TAIL"+d+key.to_s+d+value.to_s+"\n" }
end