Tomlex.StringHelpers
A set of conveniencies to use with strings.
Summary
booleanize_string(other_string) | Casts the strings |
cast_string(string) | 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 |
unquote_string(string) | Removes quotes and escaped characters from a string |
Types ↑
valid_type :: Integer.t | Float.t | boolean | String.t
Functions
Specs:
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"
Specs:
- 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"