class Diff::LCS::Change
enumerable.
addition of an element from either the old or the new sequenced
Represents a simplistic (non-contextual) change. Represents the removal or
def self.from_a(arr)
def self.from_a(arr) arr = arr.flatten(1) case arr.size when 5 Diff::LCS::ContextChange.new(*(arr[0...5])) when 3 Diff::LCS::Change.new(*(arr[0...3])) else raise "Invalid change array format provided." end end
def self.valid_action?(action)
def self.valid_action?(action) VALID_ACTIONS.include? action end
def <=>(other)
def <=>(other) r = self.action <=> other.action r = self.position <=> other.position if r.zero? r = self.element <=> other.element if r.zero? r end
def ==(other)
def ==(other) (self.class == other.class) and (self.action == other.action) and (self.position == other.position) and (self.element == other.element) end
def adding?
def adding? @action == '+' end
def changed?
def changed? @action == '!' end
def deleting?
def deleting? @action == '-' end
def finished_a?
def finished_a? @action == '>' end
def finished_b?
def finished_b? @action == '<' end
def initialize(*args)
def initialize(*args) @action, @position, @element = *args unless Diff::LCS::Change.valid_action?(@action) raise "Invalid Change Action '#{@action}'" end raise "Invalid Position Type" unless @position.kind_of? IntClass end
def inspect
def inspect to_a.inspect end
def to_a
def to_a [ @action, @position, @element ] end
def unchanged?
def unchanged? @action == '=' end