Module: StringMatchables

Included in:
String
Defined in:
lib/string_matchables.rb,
lib/string_matchables/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Instance Method Summary collapse

Instance Method Details

#matchesObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/string_matchables.rb', line 4

def matches
  
  str = self.to_s.strip
  return "" if str.empty?
  matches_arr = []

  matches_arr << str.gsub(/\s+/, "")
  matches_arr << str.gsub('-', "")
  matches_arr << str.gsub('.', "")

  matches_arr << (str.split(/\s+/)) if str.include?(" ")
  matches_arr << (str.split('-')) if str.include?('-')
  matches_arr << (str.split('.')) if str.include?('.')

  matches_arr << form_company_abbreviations(str)
  matches_arr.flatten.compact.uniq
end