Class: Rosette::Core::StringUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/rosette/core/string_utils.rb

Overview

General-purpose string manipulation utilities.

Class Method Summary collapse

Class Method Details

.camelize(str) ⇒ String

Converts a snake_cased string into a CamelCased one.

Examples:

StringUtils.camelize('foo_bar')  # => "FooBar"

Parameters:

  • str (String)

    The snake_cased string to convert.

Returns:

  • (String)

16
17
18
# File 'lib/rosette/core/string_utils.rb', line 16

def camelize(str)
  str.gsub(/(^\w|[-_]\w)/) { $1[-1].upcase }
end