disu.se

SliceClass

Namespace

Lookout::Diff

Ancestors
  1. Enumerable

  2. Comparable

  3. Value

  4. Object

Slice (subsequence) of a sequence being “diffed”.

Constructor

initialize(itemsEnumerable, rangeRange = 0...items.size)#

Initializes a slice of items encompassing range.

Instance Methods

empty?Boolean#

Returns true if #size < 1.

sizeInteger#

Returns the number of encompassed elements.

touch?(otherSlice)Boolean#

Returns true if #end + 1 = other#begin.

begin_before?(otherSlice)Boolean#

Returns true if #begin < other#begin.

end_after?(otherSlice)Boolean#

Returns true if #end > other#end.

begin_after(otherSlice)Slice#

Returns a new slice beginning at other#end + 1.

end_before(otherSlice)Slice#

Returns a new slice ending at other#begin - 1.

at(rangeRange)Slice#

Returns a new slice encompassing range.

+(otherSlice)Slice#

Returns a new slice encompassing the receiver and other.

Note

Logically, the receiver should #touch? other, but this isn’t enforced.

begin_at(indexInteger)Slice#

Returns a new slice beginning at index.

end_at(indexInteger)Slice#

Returns a new slice ending at index.

each{ |elementObject| … }self#

Enumerates the encompassed elements.

eachEnumerator<Object>#

Returns an Enumerator over the encompassed elements.

each_with_index{ |elementObject, indexInteger| … }self#

Enumerates the encompassed elements and their indexes.

each_with_indexEnumerator<Object, Integer>#

Returns an Enumerator over the encompassed elements and their indexes.

to_itemsEnumerable<Object>#

Returns the encompassed elements.

[](indexInteger)Object#

Returns the indexth element.

beginInteger#

Returns the index of the first element.

endInteger#

Returns the index of the last element.

<=>(otherSlice)Integer?#

Returns the comparison of the receiver’s #begin and #end against those of other.