Class: String

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

Instance Method Summary collapse

Instance Method Details

#camel_caseObject



2
3
4
5
# File 'lib/tccbuilder/ext/string.rb', line 2

def camel_case
  str = self.dup
  str.camel_case!
end

#camel_case!Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/tccbuilder/ext/string.rb', line 7

def camel_case!
  arr = self.split('_')
  arr.first.downcase!
  return arr.first unless arr.count > 1
  marr = [arr.first]
  marr << arr[1..arr.count].collect do |word|
    word.capitalize!
  end
  marr.join('')
end