Class: Array

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

Instance Method Summary collapse

Instance Method Details

#transitionsObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/array_transitions.rb', line 4

def transitions
  t = self.map.with_index do |e, i|
    next if self.size == i + 1

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

    { from: e, to: next_element }
  end

  t.compact
end