class Accessory::TraversalPosition::EnumerableBeforeOffset

Represents the empty intervals between and surrounding the elements of an +Enumerable#each+ traversal.

Examples to build intuition:

Attributes

elem_after[R]

@return [Object] the element after the cursor, if applicable

elem_before[R]

@return [Object] the element before the cursor, if applicable

offset[R]

@return [Integer] the offset of elem_after in the Enumerable

Public Class Methods

new(offset, elem_before, elem_after, is_first: false, is_last: false) click to toggle source

@!visibility private

# File lib/accessory/traversal_position/enumerable_before_offset.rb, line 33
def initialize(offset, elem_before, elem_after, is_first: false, is_last: false)
  @offset = offset
  @elem_before = elem_before
  @elem_after = elem_after
  @is_first = is_first
  @is_last = is_last
end

Public Instance Methods

first?() click to toggle source

@return [Boolean] true when {#elem_after} is the first element of the Enumerable

# File lib/accessory/traversal_position/enumerable_before_offset.rb, line 51
def first?; @is_first; end
last?() click to toggle source

@return [Boolean] true when {#elem_before} is the last element of the Enumerable

# File lib/accessory/traversal_position/enumerable_before_offset.rb, line 54
def last?; @is_last; end