Class: DiffRenderLog

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

Instance Method Summary collapse

Methods inherited from DiffOutputTable

#apply_row, #begin_diff, #end_diff, #quote

Methods inherited from DiffOutput

#apply_row, #begin_diff, #end_diff, #want_context

Constructor Details

#initializeDiffRenderLog

Returns a new instance of DiffRenderLog.



4
5
6
7
8
9
10
# File 'lib/coopy/diff_render_log.rb', line 4

def initialize
  @r = 0
  @c = 0
  @row_mode = ""
  @row_log = []
  @cell_log = []
end

Instance Method Details

#begin_row(mode) ⇒ Object



15
16
17
18
19
# File 'lib/coopy/diff_render_log.rb', line 15

def begin_row(mode)
  @row_mode = mode
  @row_log << [@r, mode]
  @c = 0
end

#begin_tableObject



12
13
# File 'lib/coopy/diff_render_log.rb', line 12

def begin_table
end

#end_rowObject



33
34
35
# File 'lib/coopy/diff_render_log.rb', line 33

def end_row
  @r = @r + 1
end

#end_tableObject



37
38
# File 'lib/coopy/diff_render_log.rb', line 37

def end_table
end

#insert_cell(txt, mode, separator) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/coopy/diff_render_log.rb', line 21

def insert_cell(txt,mode,separator)
  @cell_log << {
    :col => @c,
    :row => @r,
    :txt => txt,
    :cell_mode => mode,
    :row_mode => @row_mode,
    :separator => separator
  }
  @c = @c + 1
end

#logObject



40
41
42
43
44
45
46
47
# File 'lib/coopy/diff_render_log.rb', line 40

def log
  txt = ""
  @cell_log.each do |v|
    txt << v[:col].to_s + "," + v[:row].to_s + " [" + v[:cell_mode] + "/" +
      v[:row_mode] + "] " + v[:separator] + " : " + v[:txt].to_s + "\n"
  end
  txt
end

#to_stringObject



49
50
51
# File 'lib/coopy/diff_render_log.rb', line 49

def to_string
  log
end