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. @data_old[@start_old .. @end_old].each { |e| s << encode("< ") + e + encode("\n") } unless block.remove.empty? s << encode("---\n") if block.op == "!" @data_new[@start_new .. @end_new].each { |e| s << encode("> ") + e + encode("\n") } unless block.insert.empty? s end