Class: Coopy::DiffOutputStats

Inherits:
DiffOutput show all
Defined in:
lib/coopy/diff_output_stats.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DiffOutput

#begin_diff, #end_diff, #want_context

Constructor Details

#initializeDiffOutputStats

Returns a new instance of DiffOutputStats.



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

def initialize
  @row = {}
end

Instance Attribute Details

#rowObject

Returns the value of attribute row.



4
5
6
# File 'lib/coopy/diff_output_stats.rb', line 4

def row
  @row
end

Instance Method Details

#add(sel, sel_tag, tag) ⇒ Object



31
32
33
34
35
# File 'lib/coopy/diff_output_stats.rb', line 31

def add(sel,sel_tag,tag)
  v = 0
  v = sel[tag] if sel.has_key? tag
  "#{sel_tag.to_s},#{tag.to_s},#{v}\n"
end

#apply_row(rc) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/coopy/diff_output_stats.rb', line 15

def apply_row(rc)
  row_inc(:all)
  case rc.row_mode
  when "+++"
    row_inc(:insert)
  when "---"
    row_inc(:delete)
  when "->"
    row_inc(:update)
  when "..."
    row_inc(:skip)
  when ""
    row_inc(:context)
  end
end

#row_inc(tag) ⇒ Object



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

def row_inc(tag)
  @row[tag] = 0 unless @row.has_key? tag
  @row[tag] = @row[tag]+1
end

#to_stringObject



37
38
39
40
41
42
43
# File 'lib/coopy/diff_output_stats.rb', line 37

def to_string
  txt = ""
  [:all,:insert,:delete,:update,:skip,:context].each do |tag|
    txt = txt + add(@row,:row,tag)
  end
  txt
end