Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/core_ext/string.rb
Instance Method Summary collapse
-
#underscore ⇒ Object
Underscore text (downcase and replace now-char to ‘-’) Example: “some_text”.underscore # => “some-text” “R7.com”.underscore # => “r7-com”.
Instance Method Details
#underscore ⇒ Object
Underscore text (downcase and replace now-char to ‘-’)
Example:
"some_text".underscore # => "some-text"
"R7.com".underscore # => "r7-com"
7 8 9 |
# File 'lib/core_ext/string.rb', line 7 def underscore self.strip.downcase.gsub(/\W/, '-') end |