EditorConfig.Properties (EditorConfig v0.1.0)

Copy Markdown View Source

Optional typed helpers for resolved EditorConfig property maps.

Summary

Functions

Reads a case-insensitive boolean property.

Reads indent_size as a positive integer or :tab.

Functions

boolean(props, key)

@spec boolean(map(), String.t()) :: {:ok, boolean()} | :error

Reads a case-insensitive boolean property.

Examples

iex> EditorConfig.Properties.boolean(
...>   %{"trim_trailing_whitespace" => "TRUE"},
...>   "trim_trailing_whitespace"
...> )
{:ok, true}

indent_size(arg1)

@spec indent_size(map()) :: {:ok, pos_integer() | :tab} | :error

Reads indent_size as a positive integer or :tab.

Examples

iex> EditorConfig.Properties.indent_size(%{"indent_size" => "2"})
{:ok, 2}
iex> EditorConfig.Properties.indent_size(%{"indent_size" => "tab"})
{:ok, :tab}