Recase.Generic (recase v0.7.0) View Source

Generic module to split and join strings back or convert strings to atoms. This module should not be used directly.

Link to this section Summary

Functions

Splits the input and rejoins it with a separator given. Optionally converts parts to downcase, upcase or titlecase.

Atomizes a string value. Uses an existing atom if possible.

Splits the input into list. Utility function.

Link to this section Functions

Link to this function

rejoin(input, opts \\ [])

View Source

Specs

rejoin(input :: String.t(), opts :: Keyword.t()) :: String.t()

Splits the input and rejoins it with a separator given. Optionally converts parts to downcase, upcase or titlecase.

  • opts[:case] :: [:down | :up | :title | :none]
  • opts[:separator] :: binary() | integer() Default separator is ?_, default conversion is :downcase so that it behaves the same way as to_snake/1.

    Examples

    iex> Recase.Generic.rejoin "foobarBaz-λambdaΛambda-привет-Мир", separator: "_" "foobarbazλambdaλambdaприветмир"

Specs

safe_atom(String.t()) :: atom()

Atomizes a string value. Uses an existing atom if possible.

Specs

split(input :: String.t()) :: [String.t()]

Splits the input into list. Utility function.

Examples

iex> Recase.Generic.split "foo_barBaz-λambdaΛambda-привет-Мир"
["foo", "bar", "Baz", "λambda", "Λambda", "привет", "Мир"]