Add documentation to RDF.BlankNode
This commit is contained in:
parent
f62316d833
commit
5600f8c1ce
1 changed files with 16 additions and 0 deletions
|
@ -10,12 +10,28 @@ defmodule RDF.BlankNode do
|
|||
|
||||
@type t :: module
|
||||
|
||||
@doc """
|
||||
Generator function for `RDF.BlankNode`s.
|
||||
"""
|
||||
def new,
|
||||
do: new(make_ref())
|
||||
|
||||
@doc """
|
||||
Generator function for `RDF.BlankNode`s with a user-defined identity.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> RDF.bnode(:foo)
|
||||
%RDF.BlankNode{id: "foo"}
|
||||
"""
|
||||
def new(id)
|
||||
|
||||
def new(id) when is_binary(id),
|
||||
do: %RDF.BlankNode{id: id}
|
||||
|
||||
def new(id) when is_reference(id),
|
||||
do: id |> :erlang.ref_to_list |> to_string |> String.replace(~r/\<|\>/, "") |> new
|
||||
|
||||
def new(id) when is_atom(id) or is_integer(id),
|
||||
do: id |> to_string |> new
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue