Class: PatienceDiff::Html::HunkHelper
- Inherits:
-
Object
- Object
- PatienceDiff::Html::HunkHelper
- Includes:
- Escaping
- Defined in:
- lib/patience_diff/html/hunk_helper.rb
Instance Attribute Summary collapse
-
#a ⇒ Object
Returns the value of attribute a.
-
#b ⇒ Object
Returns the value of attribute b.
-
#hunk_id ⇒ Object
Returns the value of attribute hunk_id.
-
#hunk_marker ⇒ Object
Returns the value of attribute hunk_marker.
-
#last_hunk_end ⇒ Object
Returns the value of attribute last_hunk_end.
-
#opcodes ⇒ Object
Returns the value of attribute opcodes.
Instance Method Summary collapse
- #each_line ⇒ Object
- #hidden_line_count ⇒ Object
- #hunk_start ⇒ Object
-
#initialize(a, b, hunk_marker, opcodes, last_hunk_end, hunk_id) ⇒ HunkHelper
constructor
A new instance of HunkHelper.
- #lines ⇒ Object
Methods included from Escaping
Constructor Details
#initialize(a, b, hunk_marker, opcodes, last_hunk_end, hunk_id) ⇒ HunkHelper
Returns a new instance of HunkHelper.
9 10 11 12 13 14 15 16 |
# File 'lib/patience_diff/html/hunk_helper.rb', line 9 def initialize(a, b, hunk_marker, opcodes, last_hunk_end, hunk_id) @a = a @b = b @hunk_marker = hunk_marker @opcodes = opcodes @last_hunk_end = last_hunk_end @hunk_id = hunk_id end |
Instance Attribute Details
#a ⇒ Object
Returns the value of attribute a.
7 8 9 |
# File 'lib/patience_diff/html/hunk_helper.rb', line 7 def a @a end |
#b ⇒ Object
Returns the value of attribute b.
7 8 9 |
# File 'lib/patience_diff/html/hunk_helper.rb', line 7 def b @b end |
#hunk_id ⇒ Object
Returns the value of attribute hunk_id.
7 8 9 |
# File 'lib/patience_diff/html/hunk_helper.rb', line 7 def hunk_id @hunk_id end |
#hunk_marker ⇒ Object
Returns the value of attribute hunk_marker.
7 8 9 |
# File 'lib/patience_diff/html/hunk_helper.rb', line 7 def hunk_marker @hunk_marker end |
#last_hunk_end ⇒ Object
Returns the value of attribute last_hunk_end.
7 8 9 |
# File 'lib/patience_diff/html/hunk_helper.rb', line 7 def last_hunk_end @last_hunk_end end |
#opcodes ⇒ Object
Returns the value of attribute opcodes.
7 8 9 |
# File 'lib/patience_diff/html/hunk_helper.rb', line 7 def opcodes @opcodes end |
Instance Method Details
#each_line ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/patience_diff/html/hunk_helper.rb', line 30 def each_line opcodes.each do |(code, a_start, a_end, b_start, b_end)| case code when :delete a[a_start..a_end].each { |line| yield 'delete', '-' + format_line(line) } when :equal b[b_start..b_end].each { |line| yield 'equal', ' ' + format_line(line) } when :insert b[b_start..b_end].each { |line| yield 'insert', '+' + format_line(line) } end end end |
#hidden_line_count ⇒ Object
22 23 24 |
# File 'lib/patience_diff/html/hunk_helper.rb', line 22 def hidden_line_count hunk_start - @last_hunk_end - 1 end |
#hunk_start ⇒ Object
18 19 20 |
# File 'lib/patience_diff/html/hunk_helper.rb', line 18 def hunk_start @opcodes.first[3] end |
#lines ⇒ Object
26 27 28 |
# File 'lib/patience_diff/html/hunk_helper.rb', line 26 def lines @b end |