Class: Radical::Strings

Inherits:
Object
  • Object
show all
Defined in:
lib/radical/strings.rb

Constant Summary collapse

SNAKE_CASE_REGEX =
/\B([A-Z])/.freeze

Class Method Summary collapse

Class Method Details

.camel_case(str) ⇒ Object



12
13
14
# File 'lib/radical/strings.rb', line 12

def camel_case(str)
  str.split('_').map(&:capitalize).join
end

.snake_case(str) ⇒ Object



8
9
10
# File 'lib/radical/strings.rb', line 8

def snake_case(str)
  str.gsub(SNAKE_CASE_REGEX, '_\1').downcase
end