Recase (recase v0.9.1)

View Source

Recase allows you to convert string from any to any case.

This module contains public interface.

Summary

Functions

Converts string or atom to camelCase.

Converts string or atom to CONSTANT_CASE.

Converts string to dot.case

Converts string to Header-Case

Converts string to kebab-case.

Converts string to Name Case

Converts string or atom to PascalCase (aka UpperCase).

Converts string to path/case.

Converts string to Sentence case

Converts string or atom to snake_case.

Converts string to Title Case

Functions

to_camel(value)

@spec to_camel(String.t()) :: String.t()
@spec to_camel(atom()) :: atom()

Converts string or atom to camelCase.

Examples

iex> Recase.to_camel("some-value")
"someValue"

iex> Recase.to_camel("Some Value")
"someValue"

iex> Recase.to_camel(:some_value)
:someValue

to_constant(value)

@spec to_constant(String.t()) :: String.t()
@spec to_constant(atom()) :: atom()

Converts string or atom to CONSTANT_CASE.

Examples

iex> Recase.to_constant("SomeValue")
"SOME_VALUE"

iex> Recase.to_constant("some value")
"SOME_VALUE"

iex> Recase.to_constant(:someValue)
:SOME_VALUE

to_dot(value)

@spec to_dot(String.t()) :: String.t()

Converts string to dot.case

Examples

iex> Recase.to_dot("SomeValue")
"some.value"

iex> Recase.to_dot("some value")
"some.value"

to_header(value)

@spec to_header(String.t()) :: String.t()

Converts string to Header-Case

Examples

iex> Recase.to_header("SomeValue")
"Some-Value"

iex> Recase.to_header("some value")
"Some-Value"

to_kebab(value)

@spec to_kebab(String.t()) :: String.t()

Converts string to kebab-case.

Examples

iex> Recase.to_kebab("SomeValue")
"some-value"

iex> Recase.to_kebab("some value")
"some-value"

to_name(value)

@spec to_name(String.t()) :: String.t()

Converts string to Name Case

Examples

iex> Recase.to_name("mccarthy o'donnell")
"McCarthy O'Donnell"

iex> Recase.to_name("von streit")
"von Streit"

to_pascal(value)

@spec to_pascal(String.t()) :: String.t()
@spec to_pascal(atom()) :: atom()

Converts string or atom to PascalCase (aka UpperCase).

Examples

iex> Recase.to_pascal("some-value")
"SomeValue"

iex> Recase.to_pascal("some value")
"SomeValue"

iex> Recase.to_pascal(:someValue)
:SomeValue

to_path(value)

@spec to_path(String.t()) :: String.t()

to_path(value, separator)

@spec to_path(String.t(), String.t()) :: String.t()

Converts string to path/case.

Examples

iex> Recase.to_path("SomeValue")
"Some/Value"

iex> Recase.to_path("some value", "\\")
"some\\value"

to_sentence(value)

@spec to_sentence(String.t()) :: String.t()

Converts string to Sentence case

Examples

iex> Recase.to_sentence("SomeValue")
"Some value"

iex> Recase.to_sentence("some value")
"Some value"

to_snake(value)

@spec to_snake(String.t()) :: String.t()
@spec to_snake(atom()) :: atom()

Converts string or atom to snake_case.

Examples

iex> Recase.to_snake("some-value")
"some_value"

iex> Recase.to_snake("someValue")
"some_value"

iex> Recase.to_snake(:someValue)
:some_value

to_title(value)

@spec to_title(String.t()) :: String.t()

Converts string to Title Case

Examples

iex> Recase.to_title("SomeValue")
"Some Value"

iex> Recase.to_title("some value")
"Some Value"

underscore(value)

See Recase.to_snake/1.