RDF.Statement.map
You're seeing just the function
map
, go back to RDF.Statement module for more information.
Specs
map(t(), term_mapping()) :: RDF.Triple.t_values() | RDF.Quad.t_values() | nil | nil
Returns a tuple of native Elixir values from a RDF.Statement
of RDF terms.
Returns nil
if one of the components of the given tuple is not convertible via RDF.Term.value/1
.
The optional second argument allows to specify a custom mapping with a function
which 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 values/2
call.
Examples
iex> {~I<http://example.com/S>, ~I<http://example.com/p>, RDF.literal(42), ~I<http://example.com/Graph>}
...> |> RDF.Statement.map(fn
...> {:subject, subject} ->
...> subject |> to_string() |> String.last()
...> {:predicate, predicate} ->
...> predicate |> to_string() |> String.last() |> String.to_atom()
...> {:object, object} ->
...> RDF.Term.value(object)
...> {:graph_name, graph_name} ->
...> graph_name
...> end)
{"S", :p, 42, ~I<http://example.com/Graph>}