class

Similar::TextDiff(T)

Inherits Reference < Object

Captures diff op codes for textual diffs.

Constructors

new(old_tokens : Array(T), new_tokens : Array(T), algorithm : Algorithm = Algorithm::Myers, newline_terminated : Bool = false)

Creates a new text diff from already tokenized slices.

Source

Class methods

configure

Configures a text differ before diffing.

Source
from_chars(old : String, new : String) : TextDiff(String)

Creates a diff of chars.

Source
from_chars(old : Bytes, new : Bytes) : TextDiff(BytesWrapper)

Creates a diff of bytes.

Source
from_graphemes(old : String, new : String) : TextDiff(String)

Creates a diff of graphemes.

Source
from_lines(old : String, new : String) : TextDiff(String)

Creates a diff of lines.

Source
from_lines(old : Bytes, new : Bytes) : TextDiff(BytesWrapper)

Creates a diff of lines for bytes.

Source
from_slices(old : Array(U), new : Array(U)) : TextDiff(U) forall U

Creates a diff of arbitrary slices.

Source
from_unicode_words(old : String, new : String) : TextDiff(String)

Creates a diff of unicode words.

Source
from_words(old : String, new : String) : TextDiff(String)

Creates a diff of words.

Source
from_words(old : Bytes, new : Bytes) : TextDiff(BytesWrapper)

Creates a diff of words for bytes.

Source

Instance methods

algorithm

The name of the algorithm that created the diff.

Source
grouped_ops(n : Int32) : Array(Array(DiffOp))

Isolate change clusters by eliminating ranges with no changes.

Source
iter_all_changes

Flattens out the diff into all changes.

Source
iter_changes(op : DiffOp) : ChangesIter(Array(T), Array(T), T)

Iterates over the changes the op expands to.

Source
iter_inline_changes(op : DiffOp) : Array(InlineChange)

Iterates over inline changes for a diff operation.

This is like iter_changes but with inline highlight info for replace operations.

Source
new_tokens

Returns all new tokens.

Source
newline_terminated

Returns true if items in the slice are newline terminated.

Source
old_tokens

Returns all old tokens.

Source
ops

Returns the captured diff ops.

Source
ratio

Return a measure of the sequences' similarity in the range 0..=1.

Source
unified_diff

Returns a unified diff formatter.

Source