RDF.Description.map

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

Specs

Returns a map of a RDF.Description where each element from its triples is mapped with the given function.

The subject is not part of the result. If you want the subject in an outer map, just put the the description in a graph and use RDF.Graph.map/2.

The function fun will receive a tuple {statement_position, rdf_term} where statement_position is one of the atoms :predicate or :object, 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> RDF.Description.new(~I<http://example.com/S>, init: {~I<http://example.com/p>, ~L"Foo"})
...> |> RDF.Description.map(fn
...>      {:predicate, predicate} ->
...>        predicate
...>        |> to_string()
...>        |> String.split("/")
...>        |> List.last()
...>        |> String.to_atom()
...>    {_, term} ->
...>      RDF.Term.value(term)
...>    end)
%{p: ["Foo"]}