class Array

Public Instance Methods

transitions() click to toggle source
# File lib/array_transitions.rb, line 5
def transitions
  map.with_index do |e, i|
    next if size == i + 1

    next_element = self[i + 1]
    next if next_element == e

    { from: e, to: next_element }
  end.compact
end