RDF.ex v0.5.4 RDF.Boolean View Source

RDF.Datatype for XSD boolean.

Link to this section Summary

Functions

Returns an Effective Boolean Value (EBV)

Returns RDF.true if the effective boolean value of the given argument is RDF.false, or RDF.false if it is RDF.true

Returns the logical AND of the effective boolean value of the given arguments

Returns the logical OR of the effective boolean value of the given arguments

Link to this section Functions

Link to this function build_literal(value, lexical, opts) View Source
Link to this function build_literal_by_lexical(lexical, opts) View Source
Link to this function build_literal_by_value(value, opts) View Source

Returns an Effective Boolean Value (EBV).

The Effective Boolean Value is an algorithm to coerce values to a RDF.Boolean.

It is specified and used in the SPARQL query language and is based upon XPath’s fn:boolean. Other than specified in these specs any value which can not be converted into a boolean results in nil.

see

Alias for ebv/1.

Returns RDF.true if the effective boolean value of the given argument is RDF.false, or RDF.false if it is RDF.true.

Otherwise it returns nil.

Examples

iex> RDF.Boolean.fn_not(RDF.true)
RDF.false
iex> RDF.Boolean.fn_not(RDF.false)
RDF.true

iex> RDF.Boolean.fn_not(true)
RDF.false
iex> RDF.Boolean.fn_not(false)
RDF.true

iex> RDF.Boolean.fn_not(42)
RDF.false
iex> RDF.Boolean.fn_not("")
RDF.true

iex> RDF.Boolean.fn_not(nil)
nil

see https://www.w3.org/TR/xpath-functions/#func-not

Link to this function greater_than?(literal1, literal2) View Source
Link to this function less_than?(literal1, literal2) View Source
Link to this function logical_and(left, right) View Source

Returns the logical AND of the effective boolean value of the given arguments.

It returns nil if only one argument is nil and the other argument is RDF.true and RDF.false if the other argument is RDF.false.

Examples

iex> RDF.Boolean.logical_and(RDF.true, RDF.true)
RDF.true
iex> RDF.Boolean.logical_and(RDF.true, RDF.false)
RDF.false

iex> RDF.Boolean.logical_and(RDF.true, nil)
nil
iex> RDF.Boolean.logical_and(nil, RDF.false)
RDF.false
iex> RDF.Boolean.logical_and(nil, nil)
nil

see https://www.w3.org/TR/sparql11-query/#func-logical-and

Returns the logical OR of the effective boolean value of the given arguments.

It returns nil if only one argument is nil and the other argument is RDF.false and RDF.true if the other argument is RDF.true.

Examples

iex> RDF.Boolean.logical_or(RDF.true, RDF.false)
RDF.true
iex> RDF.Boolean.logical_or(RDF.false, RDF.false)
RDF.false

iex> RDF.Boolean.logical_or(RDF.true, nil)
RDF.true
iex> RDF.Boolean.logical_or(nil, RDF.false)
nil
iex> RDF.Boolean.logical_or(nil, nil)
nil

see https://www.w3.org/TR/sparql11-query/#func-logical-or

Link to this function new!(value, opts \\ %{}) View Source