tomlex v0.0.5 Tomlex.StringHelpers

A set of conveniencies to use with strings.

Summary

Functions

Casts the strings "true" and "false" to their boolean counterparts. Returns the string unchanged otherwise

Casts a string to the more appropriate elixir type. If the string cannot be casted to any of the valid types for tomlex, it will return the string unchanged

Removes quotes and escaped characters from a string

Types

valid_type()
valid_type() :: Integer.t | Float.t | boolean | String.t

Functions

booleanize_string(other_string)
booleanize_string(String.t) :: boolean | String.t

Casts the strings "true" and "false" to their boolean counterparts. Returns the string unchanged otherwise.

Examples

iex> Tomlex.StringHelpers.booleanize_string("true")
true

iex> Tomlex.StringHelpers.booleanize_string("not boolean")
"not boolean"
cast_string(string)
cast_string(String.t) :: valid_type

Casts a string to the more appropriate elixir type. If the string cannot be casted to any of the valid types for tomlex, it will return the string unchanged.

Examples

iex> Tomlex.StringHelpers.cast_string("123")
123

iex> Tomlex.StringHelpers.cast_string("123.4")
123.4

iex> Tomlex.StringHelpers.cast_string("false")
false

iex> Tomlex.StringHelpers.cast_string("random string")
"random string"
unquote_string(string)
unquote_string(String.t) :: String.t

Removes quotes and escaped characters from a string.

Examples

iex> Tomlex.StringHelpers.unquote_string("\"value\"\\n23")
"value\n23"