Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/transit/support/string.rb
Overview
Extends string to create url friendly formatted values. Original implemention by Ludo van den Boom
Direct Known Subclasses
Instance Method Summary (collapse)
-
- (Object) to_slug
Removes all non url-friendly characters and replaces spaces and underscores with hyphens.
Instance Method Details
- (Object) to_slug
Removes all non url-friendly characters and replaces spaces and underscores with hyphens.
12 13 14 15 16 17 18 19 20 |
# File 'lib/transit/support/string.rb', line 12 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 |