class Diff::LCS::Hunk
def old_diff
Note that an old diff can't have any context. Therefore, we know that
def old_diff warn 'Expecting only one block in an old diff hunk!' if @blocks.size > 1 op_act = { '+' => 'a', '-' => 'd', '!' => 'c' } block = @blocks[0] # Calculate item number range. Old diff range is just like a context # diff range, except the ranges are on one line with the action between # them. s = encode("#{context_range(:old)}#{op_act[block.op]}#{context_range(:new)}\n") # If removing anything, just print out all the remove lines in the hunk # which is just all the remove lines in the block. unless block.remove.empty? @data_old[@start_old..@end_old].each { |e| s << encode('< ') + e + encode("\n") } end s << encode("---\n") if block.op == '!' unless block.insert.empty? @data_new[@start_new..@end_new].each { |e| s << encode('> ') + e + encode("\n") } end s end