Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/tracetool/utils/string.rb
Overview
Extended string class rubocop:disable Style/ClassAndModuleChildren
Instance Method Summary collapse
-
#longest_common_postfix(other) ⇒ String
Return longest common postfix.
Instance Method Details
#longest_common_postfix(other) ⇒ String
Return longest common postfix
10 11 12 13 14 15 16 17 18 19 20 |
# 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 |