Module: Savon::CoreExt::String::Extension

Defined in:
lib/savon/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#snakecaseObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/savon/core_ext/string.rb', line 13

def snakecase
  str = dup
  str.gsub! /::/, '/'
  str.gsub! /([A-Z]+)([A-Z][a-z])/, '\1_\2'
  str.gsub! /([a-z\d])([A-Z])/, '\1_\2'
  str.tr! ".", "_"
  str.tr! "-", "_"
  str.downcase!
  str
end