Module: Miasma::Utils::AnimalStrings

Included in:
Miasma::Utils
Defined in:
lib/miasma/utils/animal_strings.rb

Overview

Animal stylings on strings

Instance Method Summary (collapse)

Instance Method Details

- (String) camel(string)

Camel case string

Parameters:

  • string (String)

Returns:

  • (String)


12
13
14
# File 'lib/miasma/utils/animal_strings.rb', line 12

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

- (String) snake(string)

Snake case (underscore) string

Parameters:

  • string (String)

Returns:

  • (String)


20
21
22
# File 'lib/miasma/utils/animal_strings.rb', line 20

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