View Source ElixirCLRut.Formatter (ElixirCLRUT v1.0.3)

Cleans and give format to RUT strings.

Link to this section Summary

Functions

Removes all chars (except for numbers and letter K) from the RUT.

Adds dots to a list of rut characters.

Gives format to a normalized RUT.

Transforms a RUT string to a list of numbers. Converts lowercase to uppercase.

Link to this section Functions

Link to this function

clean(input)

View Source (since 1.0.0)
@spec clean(String.t()) :: String.t()

Removes all chars (except for numbers and letter K) from the RUT.

examples

Examples

iex> clean("2228250-6")
"22282506"

iex> clean("14.193.432-5")
"141934325"
Link to this function

dots(list, sep \\ ".", every \\ 3)

View Source (since 1.0.1)
@spec dots(list(), String.t(), integer()) :: String.t()

Adds dots to a list of rut characters.

examples

Examples

iex> dots([2, 0, 9, 6, 1, 6, 0, 5])
"20.961.605"

iex> dots([2, 0, 9, 6, 1, 6, 0, 5], ",")
"20,961,605"

iex> dots([2, 0, 9, 6, 1, 6, 0, 5], ",", 3)
"20,961,605"
Link to this function

format(rut, options \\ [separator: "."])

View Source (since 1.0.1)
@spec format(
  struct(),
  list() | String.t()
) :: String.t()

Gives format to a normalized RUT.

examples

Examples

iex> format(ElixirCLRut.from("20961605-K"))
"20.961.605-K"
iex> format(ElixirCLRut.from("141231553"))
"14.123.155-3"
iex> format(ElixirCLRut.from("141231553"), separator: "")
"14123155-3"
iex> format(ElixirCLRut.from("14123155", false))
"14.123.155-3"
Link to this function

normalize(input)

View Source (since 1.0.0)
@spec normalize(String.t()) :: String.t()

Transforms a RUT string to a list of numbers. Converts lowercase to uppercase.

examples

Examples

iex> normalize("2228250-6")
[2, 2, 2, 8, 2, 5, 0, 6]

iex> normalize("14.193.432-5")
[1, 4, 1, 9, 3, 4, 3, 2, 5]