Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/rstack/core_ext.rb

Instance Method Summary collapse

Instance Method Details

#camelizeObject



35
36
37
# File 'lib/rstack/core_ext.rb', line 35

def camelize
  self.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
end

#underscoreObject



27
28
29
30
31
32
33
# File 'lib/rstack/core_ext.rb', line 27

def underscore
  self.gsub(/::/, '/').
    gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
    gsub(/([a-z\d])([A-Z])/,'\1_\2').
    tr("-", "_").
    downcase
end