Module: Transit::CoreExt::String

Defined in:
lib/transit/core_ext.rb

Instance Method Summary collapse

Instance Method Details

#to_slugObject



5
6
7
8
9
10
11
12
13
# File 'lib/transit/core_ext.rb', line 5

def to_slug
  value = self.mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n, '').to_s
  value.gsub!(/[']+/, '')
  value.gsub!(/\W+/, ' ')
  value.strip!
  value.downcase!
  value.gsub!(' ', '-')
  value
end