Module: Magent::Utils
- Defined in:
- lib/magent/utils.rb
Class Method Summary collapse
Class Method Details
.camelize(word) ⇒ Object
9 10 11 |
# File 'lib/magent/utils.rb', line 9 def self.camelize(word) word.to_s.gsub(/\.(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } end |
.underscore(word) ⇒ Object
3 4 5 6 7 |
# File 'lib/magent/utils.rb', line 3 def self.underscore(word) word.to_s.gsub(/::/, '.'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase end |