RDF.Quad.map

You're seeing just the function map, go back to RDF.Quad module for more information.

Specs

map(t(), RDF.Statement.term_mapping()) :: t_values() | nil

Returns a tuple where each element from a RDF.Quad is mapped with the given function.

Returns nil if one of the components of the given tuple is not convertible via RDF.Term.value/1.

The function fun will receive a tuple {statement_position, rdf_term} where statement_position is one of the atoms :subject, :predicate, :object or :graph_name while rdf_term is the RDF term to be mapped. When the given function returns nil this will be interpreted as an error and will become the overhaul result of the map/2 call.

Examples

iex> {~I<http://example.com/S>, ~I<http://example.com/p>, RDF.literal(42), ~I<http://example.com/Graph>}
...> |> RDF.Quad.map(fn
...>      {:object, object} ->
...>        RDF.Term.value(object)
...>      {:graph_name, graph_name} ->
...>        graph_name
...>      {_, resource} ->
...>        resource |> to_string() |> String.last() |> String.to_atom()
...>    end)
{:S, :p, 42, ~I<http://example.com/Graph>}