Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/henshin/ext.rb
Instance Method Summary collapse
-
#numeric? ⇒ Boolean
Checks whether it is a valid number in a string, or not.
-
#slugify ⇒ String
Turns the string to a slug.
-
#to_p ⇒ Pathname
Converts the String to a Pathname object.
Instance Method Details
#numeric? ⇒ Boolean
Checks whether it is a valid number in a string, or not
25 26 27 |
# File 'lib/henshin/ext.rb', line 25 def numeric? true if Float(self) rescue false end |
#slugify ⇒ String
Turns the string to a slug
6 7 8 9 10 11 12 13 14 |
# File 'lib/henshin/ext.rb', line 6 def slugify slug = self.clone slug.gsub!(/[']+/, '') slug.gsub!(/\W+/, ' ') slug.strip! slug.downcase! slug.gsub!(' ', '-') slug end |