View Source Rivet.Utils.Enum (rivet_utils v2.0.1)

Contributor: Brandon Gillespie

Summary

Functions

like Enum.find_value() on a list of [{rx, fn}, ..], calling fn on the matched rx and returning the result.

Functions

like Enum.find_value() on a list of [{rx, fn}, ..], calling fn on the matched rx and returning the result.

iex> opts = [ ...> {~r/^(\d+)\s(m|min(s)?|minute(s)?)$/, fn match, _ -> {:min, match} end}, ...> {~r/^(\d+)\s(h|hour(s)?|hr(s)?)$/, fn match, _ -> {:hr, match} end}, ...> ] ...> enum_rx(opts, "30 m")

iex> enum_rx(opts, "1.5 hr") # doesn't match because of the period nil