Class: Card::Content::Diff::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/card/content/diff/result.rb

Overview

Result object for Diff processing

Defined Under Namespace

Classes: Summary

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(summary_opts = nil) ⇒ Result

Returns a new instance of Result.



7
8
9
10
11
12
# File 'lib/card/content/diff/result.rb', line 7

def initialize summary_opts=nil
  @dels_cnt = 0
  @adds_cnt = 0
  @complete = ""
  @summary = Summary.new summary_opts
end

Instance Attribute Details

#adds_cntObject

Returns the value of attribute adds_cnt.



6
7
8
# File 'lib/card/content/diff/result.rb', line 6

def adds_cnt
  @adds_cnt
end

#completeObject

Returns the value of attribute complete.



6
7
8
# File 'lib/card/content/diff/result.rb', line 6

def complete
  @complete
end

#dels_cntObject

Returns the value of attribute dels_cnt.



6
7
8
# File 'lib/card/content/diff/result.rb', line 6

def dels_cnt
  @dels_cnt
end

#summaryObject

Returns the value of attribute summary.



6
7
8
# File 'lib/card/content/diff/result.rb', line 6

def summary
  @summary
end

Instance Method Details

#summary_omits_content?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/card/content/diff/result.rb', line 18

def summary_omits_content?
  @summary.omits_content?
end

#write_added_chunk(text) ⇒ Object



22
23
24
25
26
# File 'lib/card/content/diff/result.rb', line 22

def write_added_chunk text
  @adds_cnt += 1
  @complete << Card::Content::Diff.render_added_chunk(text)
  @summary.add text
end

#write_deleted_chunk(text) ⇒ Object



28
29
30
31
32
# File 'lib/card/content/diff/result.rb', line 28

def write_deleted_chunk text
  @dels_cnt += 1
  @complete << Card::Content::Diff.render_deleted_chunk(text)
  @summary.delete text
end

#write_excluded_chunk(text) ⇒ Object



39
40
41
# File 'lib/card/content/diff/result.rb', line 39

def write_excluded_chunk text
  @complete << text
end

#write_unchanged_chunk(text) ⇒ Object



34
35
36
37
# File 'lib/card/content/diff/result.rb', line 34

def write_unchanged_chunk text
  @complete << text
  @summary.omit
end