Module: WhoCalledMe::StringUtils
- Defined in:
- lib/who_called_me/utils/string_utils.rb
Class Method Summary collapse
Class Method Details
.common_substring(a, b) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/who_called_me/utils/string_utils.rb', line 8 def self.common_substring(a, b) difference = a.to_str.each_char.with_index.find { |ch, idx| b[idx].nil? or ch != b[idx].chr } difference ? b[0, difference.last] : b end |
.have_common_substring?(a, b) ⇒ Boolean
4 5 6 |
# File 'lib/who_called_me/utils/string_utils.rb', line 4 def self.have_common_substring?(a, b) 1 <= common_substring(a, b).length end |