Class: String

Inherits:
Object show all
Defined in:
lib/ezframe/util.rb

Instance Method Summary collapse

Instance Method Details

#to_camelObject



16
17
18
# File 'lib/ezframe/util.rb', line 16

def to_camel
  self.split("_").map{|w| w[0] = w[0].upcase; w}.join
end

#to_snakeObject



12
13
14
# File 'lib/ezframe/util.rb', line 12

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