Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/windcave_rest/models/base.rb

Overview

to convert from snake case to camel case in String

Instance Method Summary collapse

Instance Method Details

#camel_caseObject



144
145
146
147
# File 'lib/windcave_rest/models/base.rb', line 144

def camel_case
  return self if self !~ /_/ && self =~ /[A-Z]+.*/
  split('_').map{|e| e.capitalize}.join
end

#camel_case_lowerObject



149
150
151
# File 'lib/windcave_rest/models/base.rb', line 149

def camel_case_lower
  self.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
end