Method: Array#suffix

Defined in:
lib/snmputils/arrayutils.rb

#suffixObject

Calculate the longest common suffix for all elements in the array.

Requires array elements to support size and take operations

Examples:

[‘y’, ‘z’], [‘w’, ‘x’, ‘y’, ‘z’], [‘u’, ‘v’, ‘y’, ‘z’]].suffix # => [‘y’, ‘z’

Returns:

  • (Object)

    The largest common suffix for all elements in the array



46
47
48
49
# File 'lib/snmputils/arrayutils.rb', line 46

def suffix 
  prefix = (map { |x| x != nil && x.reverse }).prefix
  prefix.reverse if prefix
end