Sha256: d46c46cb3e37a098d38607140d9f7709ba84cf4e9050759b68ba916662c8c2c5
Contents?: true
Size: 382 Bytes
Versions: 34
Compression:
Stored size: 382 Bytes
Contents
class String def optionize(sep = '-') result = downcase.strip # Turn unwanted chars into the separator result.gsub!(/[^a-z0-9\-_]+/, sep) re_sep = Regexp.escape(sep) # No more than one of the separator in a row. result.gsub!(/#{re_sep}{2,}/, sep) result.underscore end alias_method :slugify, :optionize alias_method :systemize, :optionize end
Version data entries
34 entries across 34 versions & 1 rubygems