Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/any_view/core_ext/string.rb
Instance Method Summary collapse
Instance Method Details
#titleize ⇒ Object
3 4 5 |
# File 'lib/any_view/core_ext/string.rb', line 3 def titleize gsub("_", " ").gsub(/\b('?[a-z])/){$1.upcase} end |
#underscore ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/any_view/core_ext/string.rb', line 9 def underscore gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). gsub("-", "_"). downcase end |