Class: String

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

Instance Method Summary collapse

Instance Method Details

#camelizeObject



2
3
4
# File 'lib/lathe/string.rb', line 2

def camelize
  dup.camelize!
end

#camelize!Object



5
6
7
# File 'lib/lathe/string.rb', line 5

def camelize!
  self.replace(self.split("_").each {|s| s.capitalize! }.join(""))
end

#underscoreObject



8
9
10
# File 'lib/lathe/string.rb', line 8

def underscore
  dup.underscore!
end

#underscore!Object



11
12
13
# File 'lib/lathe/string.rb', line 11

def underscore!
  self.replace(self.scan(/[A-Z][a-z]*/).join("_").downcase)
end