Class: String

Inherits:
Object show all
Defined in:
lib/attrio/core_ext/string.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#camelizeObject



12
13
14
# File 'lib/attrio/core_ext/string.rb', line 12

def camelize
  self.split(/[^a-z0-9]/i).map{|w| w.capitalize}.join
end

#underscoreObject



4
5
6
7
8
9
10
# File 'lib/attrio/core_ext/string.rb', line 4

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