Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/array_transitions.rb

Instance Method Summary collapse

Instance Method Details

#transitionsObject



5
6
7
8
9
10
11
12
13
14
# 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