Class: SimpleSlugs::Slug
Instance Method Summary collapse
- #dasherize ⇒ Object
-
#initialize(string) ⇒ Slug
constructor
A new instance of Slug.
- #normalize ⇒ Object
- #spacify ⇒ Object
- #transliterate ⇒ Object
Methods inherited from String
Constructor Details
#initialize(string) ⇒ Slug
Returns a new instance of Slug.
3 4 5 6 |
# File 'lib/simple_slugs/slug.rb', line 3 def initialize(string) super normalize end |
Instance Method Details
#dasherize ⇒ Object
24 25 26 |
# File 'lib/simple_slugs/slug.rb', line 24 def dasherize gsub!(' ', '-') end |
#normalize ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/simple_slugs/slug.rb', line 8 def normalize transliterate spacify strip! downcase! dasherize end |
#spacify ⇒ Object
20 21 22 |
# File 'lib/simple_slugs/slug.rb', line 20 def spacify gsub!(/[\W_]/, ' ') end |
#transliterate ⇒ Object
16 17 18 |
# File 'lib/simple_slugs/slug.rb', line 16 def transliterate replace(I18n.transliterate(self)) end |