Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/string_ext.rb
Instance Method Summary collapse
- #camelize ⇒ Object
-
#underscore ⇒ Object
taken from active-support.
Instance Method Details
#camelize ⇒ Object
11 12 13 |
# File 'lib/string_ext.rb', line 11 def camelize gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } end |
#underscore ⇒ Object
taken from active-support
3 4 5 6 7 8 9 |
# File 'lib/string_ext.rb', line 3 def underscore gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end |