class PatienceDiff::Html::HunkHelper
Attributes
a[RW]
b[RW]
hunk_id[RW]
hunk_marker[RW]
last_hunk_end[RW]
opcodes[RW]
Public Class Methods
new(a, b, hunk_marker, opcodes, last_hunk_end, hunk_id)
click to toggle source
# 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
Public Instance Methods
each_line() { |'delete', '-' + format_line(line)| ... }
click to toggle source
# 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
hunk_start()
click to toggle source
# File lib/patience_diff/html/hunk_helper.rb, line 18 def hunk_start @opcodes.first[3] end
lines()
click to toggle source
# File lib/patience_diff/html/hunk_helper.rb, line 26 def lines @b end
Private Instance Methods
format_line(line)
click to toggle source
override for additional behavior, e.g. syntax highlighting
# File lib/patience_diff/html/hunk_helper.rb, line 45 def format_line(line) escape(line) end