Module: Slugity::Convert
- Defined in:
- lib/slugity/convert.rb
Class Method Summary collapse
-
.slug(string, matcher = :default) ⇒ String
Converts the given string into a slug.
-
.string(string, matcher = :default) ⇒ String
Converts the given string with the provided matcher.
Class Method Details
.slug(string, matcher = :default) ⇒ String
Converts the given string into a slug
9 10 11 12 13 |
# File 'lib/slugity/convert.rb', line 9 def self.slug string, matcher=:default string = Slugity::Convert.string( string, matcher ).downcase string.gsub!( /[^a-z0-9\-\_]/, '' ) return string end |
.string(string, matcher = :default) ⇒ String
Converts the given string with the provided matcher
20 21 22 23 24 25 26 27 28 |
# File 'lib/slugity/convert.rb', line 20 def self.string string, matcher=:default string = Util.normalize_string( string ) Slugity::Matchers.use(matcher).each do |match, replacement| string.gsub!( match, replacement ) end return string end |