Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/roart/core/string.rb
Overview
used from ActiveSupport Copyright © 2005-2009 David Heinemeier Hansson
Instance Method Summary collapse
Instance Method Details
#camelize ⇒ Object
14 15 16 |
# File 'lib/roart/core/string.rb', line 14 def camelize self.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } end |
#humanize ⇒ Object
18 19 20 |
# File 'lib/roart/core/string.rb', line 18 def humanize self.gsub(/_id$/, "").gsub(/_/, " ").capitalize end |
#underscore ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/roart/core/string.rb', line 6 def underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end |