vendor/gems/diff-lcs-1.1.2/lib/diff/lcs/hunk.rb
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 = "#{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 << "< #{e}\n" } unless block.remove.empty?
    s << "---\n" if block.op == "!"
    @data_new[@start_new .. @end_new].each { |e| s << "> #{e}\n" } unless block.insert.empty?
    s
  end
# Note that an old diff can't have any context. Therefore, we know that
# there's only one block in the hunk.
Note that an old diff can't have any context. Therefore, we know that
there's only one block in the hunk.
Note that an old diff can ' t have any context . Therefore we know that there ' s only one block in the hunk .
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]
    s = "#{context_range(:old)}#{op_act[block.op]}#{context_range(:new)}\n"
    @data_old[@start_old .. @end_old].each { |e| s << "< #{e}\n" } unless block.remove.empty?
    s << "---\n" if block.op == "!"
    @data_new[@start_new .. @end_new].each { |e| s << "> #{e}\n" } unless block.insert.empty?
    s
  end
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 ] s = "#{context_range(:old)}#{op_act[block.op]}#{context_range(:new)}\n" @data_old [ @start_old .. @end_old ] . each { | e | s << "< #{e}\n" } unless block . remove . empty? s << "---\n" if block . op == "!" @data_new [ @start_new .. @end_new ] . each { | e | s << "> #{e}\n" } unless block . insert . empty? s end
Note that an old diff can't have any context.
Note that an old diff can ' t have any context .
# 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. # If removing anything, just print out all the remove lines in the hunk # which is just all the remove lines in the block.