Add RDF.Dataset.graph_count/1

This commit is contained in:
Marcel Otto 2021-11-10 00:43:57 +01:00
parent 89947590cb
commit f9c72c1a35
2 changed files with 19 additions and 0 deletions

View File

@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/) and
### Added
- support for `RDF.PropertyMap` on `RDF.Statement.new/2` and `RDF.Statement.coerce/2`
- `RDF.Dataset.graph_count/1`
### Changed

View File

@ -532,6 +532,24 @@ defmodule RDF.Dataset do
end
end
@doc """
The number of graphs within a `RDF.Dataset`.
## Examples
iex> RDF.Dataset.new([
...> {EX.S1, EX.p1, EX.O1},
...> {EX.S2, EX.p2, EX.O2},
...> {EX.S1, EX.p2, EX.O3, EX.Graph}])
...> |> RDF.Dataset.graph_count()
2
"""
@spec graph_count(t) :: non_neg_integer
def graph_count(%__MODULE__{} = dataset) do
Enum.count(dataset.graphs)
end
@doc """
The number of statements within a `RDF.Dataset`.