Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/shot_mvc/controller_loader.rb
Instance Method Summary collapse
- #camelize ⇒ Object
-
#underscore ⇒ Object
Converts a CamelCased string to a underscore_string.
Instance Method Details
#camelize ⇒ Object
24 25 26 27 28 |
# File 'lib/shot_mvc/controller_loader.rb', line 24 def camelize parts = self.split '_' parts.map! do |part| part.capitalize end parts.join '' end |
#underscore ⇒ Object
Converts a CamelCased string to a underscore_string
16 17 18 19 20 21 22 |
# File 'lib/shot_mvc/controller_loader.rb', line 16 def underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end |