Class Diff::LCS::Hunk
In: lib/diff/lcs/hunk.rb
Parent: Object

A Hunk is a group of Blocks which overlap because of the context surrounding each block. (So if we‘re not using context, every hunk will contain one block.) Used in the diff program (bin/diff).

Methods

diff   merge   new   overlaps?   unshift  

Attributes

blocks  [R] 
end_new  [R] 
end_old  [R] 
file_length_difference  [R] 
flag_context  [RW]  Change the "start" and "end" fields to note that context should be added to this hunk.
start_new  [R] 
start_old  [R] 

Public Class methods

Create a hunk using references to both the old and new data, as well as the piece of data.

Public Instance methods

Returns a diff string based on a format.

Merges this hunk and the provided hunk together if they overlap. Returns a truthy value so that if there is no overlap, you can know the merge was skipped.

Determines whether there is an overlap between this hunk and the provided hunk. This will be true if the difference between the two hunks start or end positions is within one position of each other.

unshift(hunk)

Alias for merge

[Validate]