RDF.Literal.coerce

You're seeing just the function coerce, go back to RDF.Literal module for more information.

Coerces a new RDF.Literal from another value.

The following mapping of Elixir types to XSD datatypes is applied:

Elixir datatypeXSD datatype
stringxsd:string
booleanxsd:boolean
integerxsd:integer
floatxsd:double
Decimalxsd:decimal
Timexsd:time
Datexsd:date
DateTimexsd:dateTime
NaiveDateTimexsd:dateTime
URIxsd:AnyURI

When an RDF.Literal can not be coerced, nil is returned (as opposed to new/1 which fails in this case).

Examples

iex> RDF.Literal.coerce(42)
%RDF.Literal{literal: %RDF.XSD.Integer{value: 42}}