ymlr v0.0.1 Ymlr.Encoder
Encodes data into YAML strings.
Link to this section Summary
Functions
Encodes the given data as YAML string.
Encodes the given data as YAML string. Raises if it cannot be encoded.
Link to this section Types
Link to this section Functions
Link to this function
to_s(data)
Specs
Encodes the given data as YAML string.
Examples
iex> Ymlr.Encoder.to_s(%{a: 1, b: 2})
{:ok, "a: 1\nb: 2"}
iex> Ymlr.Encoder.to_s({"a", "b"})
{:error, "The given data {\"a\", \"b\"} cannot be converted to YAML."}
Link to this function
to_s!(data)
Specs
Encodes the given data as YAML string. Raises if it cannot be encoded.
Examples
iex> Ymlr.Encoder.to_s!(%{})
"{}"
iex> Ymlr.Encoder.to_s!(%{a: 1, b: 2})
"a: 1\nb: 2"
iex> Ymlr.Encoder.to_s!(%{"a" => "a", "b" => :b, "c" => "true", "d" => "100"})
"a: a\nb: b\nc: 'true'\nd: '100'"
iex> Ymlr.Encoder.to_s!({"a", "b"})
** (ArgumentError) The given data {"a", "b"} cannot be converted to YAML.