Method: Howzit::StringUtils#to_rx

Defined in:
lib/howzit/stringutils.rb

#to_rxRegexp

Convert a string to a regex object based on matching settings



91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/howzit/stringutils.rb', line 91

def to_rx
  case Howzit.options[:matching]
  when 'exact'
    /^#{self}$/i
  when 'beginswith'
    /^#{self}/i
  when 'fuzzy'
    /#{split(//).join('.{0,3}?')}/i
  else
    /#{self}/i
  end
end