class Diff::LCS::Block

A block is an operation removing, adding, or changing a group of items. Basically, this is just a list of changes, where each change adds or deletes a single item. Used by bin/ldiff.

Attributes

changes[R]
insert[R]
remove[R]

Public Class Methods

new(chunk) click to toggle source
# File lib/diff/lcs/block.rb, line 8
def initialize(chunk)
  @changes = []
  @insert = []
  @remove = []

  chunk.each do |item|
    @changes << item
    @remove << item if item.deleting?
    @insert << item if item.adding?
  end
end

Public Instance Methods

diff_size() click to toggle source
# File lib/diff/lcs/block.rb, line 20
def diff_size
  @insert.size - @remove.size
end
op() click to toggle source
# File lib/diff/lcs/block.rb, line 24
def op
  case [@remove.empty?, @insert.empty?]
  when [false, false]
    '!'
  when [false, true]
    '-'
  when [true, false]
    '+'
  else # [true, true]
    '^'
  end
end