Module: SparkleFormation::Utils::AnimalStrings

Included in:
SparkleFormation, SparkleFormation, Resources, Translation
Defined in:
lib/sparkle_formation/utils.rb

Overview

Animal stylings on strins

Instance Method Summary collapse

Instance Method Details

#camel(string) ⇒ String

Camel case string

Parameters:

  • string (String)

Returns:

  • (String)


51
52
53
# File 'lib/sparkle_formation/utils.rb', line 51

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

#snake(string) ⇒ String

Snake case (underscore) string

Parameters:

  • string (String)

Returns:

  • (String)


59
60
61
# File 'lib/sparkle_formation/utils.rb', line 59

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