Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/dmap/core.rb
Overview
We’ll be needing to convert to CamelCase and under_score quite a bit
Instance Method Summary collapse
Instance Method Details
#camelcase ⇒ Object
3 4 5 |
# File 'lib/dmap/core.rb', line 3 def camelcase self.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } end |
#underscore ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/dmap/core.rb', line 7 def underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end |