Module: KnifeCloudformation::Utils::AnimalStrings

Included in:
MonkeyPatch::Stack, Provider, KnifeCloudformation::Utils, StackExporter, StackParameterValidator
Defined in:
lib/knife-cloudformation/utils/animal_strings.rb

Overview

Helper methods for string format modification

Instance Method Summary collapse

Instance Method Details

#camel(string) ⇒ String

Camel case string

Parameters:

  • string (String)

Returns:

  • (String)


13
14
15
# File 'lib/knife-cloudformation/utils/animal_strings.rb', line 13

def camel(string)
  string.to_s.split('_').map{|k| "#{k.slice(0,1).upcase}#{k.slice(1,k.length)}"}.join
end

#snake(string) ⇒ Symbol

Snake case string

Parameters:

  • string (String)

Returns:

  • (Symbol)


21
22
23
# File 'lib/knife-cloudformation/utils/animal_strings.rb', line 21

def snake(string)
  string.to_s.gsub(/([a-z])([A-Z])/, '\1_\2').downcase.to_sym
end