Class: DiffRenderCsv

Inherits:
DiffOutputTable show all
Defined in:
lib/coopy/diff_render_csv.rb

Instance Method Summary collapse

Methods inherited from DiffOutputTable

#apply_row, #begin_diff, #begin_table, #end_diff, #end_table, #quote

Methods inherited from DiffOutput

#apply_row, #begin_diff, #end_diff, #want_context

Constructor Details

#initialize(fname = nil) ⇒ DiffRenderCsv

Returns a new instance of DiffRenderCsv.



5
6
7
8
# File 'lib/coopy/diff_render_csv.rb', line 5

def initialize(fname = nil)
  @txt = ""
  @csv = CSV.open(fname,'w') if fname
end

Instance Method Details

#begin_row(row_mode) ⇒ Object



10
11
12
# File 'lib/coopy/diff_render_csv.rb', line 10

def begin_row(row_mode)
  @line = []
end

#end_rowObject



18
19
20
21
22
23
24
# File 'lib/coopy/diff_render_csv.rb', line 18

def end_row
  if @csv
    @csv.add_row(@line)
  else
    @txt << @line.to_csv
  end
end

#insert_cell(txt, mode, separator) ⇒ Object



14
15
16
# File 'lib/coopy/diff_render_csv.rb', line 14

def insert_cell(txt,mode,separator)
  @line << txt
end

#to_stringObject



26
27
28
# File 'lib/coopy/diff_render_csv.rb', line 26

def to_string
  @txt
end