Add RDF.IRI.append/2
This commit is contained in:
parent
71292b721c
commit
ec0e60e3c8
2 changed files with 26 additions and 0 deletions
|
@ -29,6 +29,7 @@ are specified.
|
|||
- to `RDF.Dataset`
|
||||
- `RDF.Dataset.name/1`
|
||||
- `RDF.Dataset.change_name/2`
|
||||
- `RDF.IRI.append/2`
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -69,6 +69,31 @@ defmodule RDF.IRI do
|
|||
def new!(%URI{} = uri), do: uri |> valid!() |> new()
|
||||
def new!(%__MODULE__{} = iri), do: valid!(iri)
|
||||
|
||||
@doc """
|
||||
Appends a String to a `RDF.IRI`.
|
||||
|
||||
## Example
|
||||
|
||||
iex> ~I<http://example.com/> |> RDF.IRI.append("foo")
|
||||
~I<http://example.com/foo>
|
||||
|
||||
iex> EX.foo |> RDF.IRI.append("bar")
|
||||
EX.foobar
|
||||
|
||||
iex> EX.Foo |> RDF.IRI.append("bar")
|
||||
RDF.iri(EX.Foobar)
|
||||
"""
|
||||
@spec append(t | module, String.t()) :: t
|
||||
def append(iri, string)
|
||||
|
||||
def append(%__MODULE__{} = iri, string) do
|
||||
%__MODULE__{iri | value: iri.value <> string}
|
||||
end
|
||||
|
||||
def append(term, string) when maybe_ns_term(term) do
|
||||
term |> Namespace.resolve_term!() |> append(string)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Coerces an IRI serving as a base IRI.
|
||||
|
||||
|
|
Loading…
Reference in a new issue