class String

Extended string class rubocop:disable Style/ClassAndModuleChildren

Public Instance Methods

longest_common_postfix(other) click to toggle source

Return longest common postfix @param [String] other other string to match @return [String] longest common postfix

# File lib/tracetool/utils/string.rb, line 10
def longest_common_postfix(other)
  sidx = length - 1
  oidx = other.length - 1

  while sidx >= 0 && oidx >= 0 && (self[sidx] == other[oidx])
    sidx -= 1
    oidx -= 1
  end

  other[(oidx + 1)..-1]
end