Class: String

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

Instance Method Summary collapse

Instance Method Details

#camelizeObject



37
38
39
# File 'lib/rebrandly.rb', line 37

def camelize
  self.split('_').collect(&:capitalize).join
end

#lower_camelizeObject



41
42
43
44
# File 'lib/rebrandly.rb', line 41

def lower_camelize
  res = self.camelize
  res[0].downcase + res[1..-1]
end

#underscoreObject



29
30
31
32
33
34
35
# File 'lib/rebrandly.rb', line 29

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