Module: RDF::Value

Included in:
Statement, Term
Defined in:
lib/rdf/nquads.rb,
lib/rdf/ntriples.rb,
lib/rdf/model/value.rb

Overview

An RDF value.

This is the basis for the RDF.rb class hierarchy. Anything that can be a term of RDF statements should directly or indirectly include this module.

Examples:

Checking if a value is a resource (blank node or URI reference)

value.resource?

Checking if a value is a blank node

value.node?

Checking if a value is a URI reference

value.uri?
value.iri?

Checking if a value is a literal

value.literal?

See Also:

Instance Method Summary collapse

Instance Method Details

#graph?Boolean

Returns ‘true` if `self` is a graph.

Returns:

  • (Boolean)


33
34
35
# File 'lib/rdf/model/value.rb', line 33

def graph?
  false
end

#inspectString

Returns a developer-friendly representation of ‘self`.

The result will be of the format ‘#<RDF::Value::0x12345678(…)>`, where `…` is the string returned by `#to_s`.

Returns:

  • (String)


111
112
113
# File 'lib/rdf/model/value.rb', line 111

def inspect
  sprintf("#<%s:%#0x(%s)>", self.class.name, __id__, to_s)
end

#inspect!void

This method returns an undefined value.

Outputs a developer-friendly representation of ‘self` to `stderr`.



119
120
121
# File 'lib/rdf/model/value.rb', line 119

def inspect!
  warn(inspect)
end

#iri?Boolean

Returns ‘true` if `self` is an IRI reference.

By default this is simply an alias for #uri?.

Returns:

  • (Boolean)


75
76
77
# File 'lib/rdf/model/value.rb', line 75

def iri?
  uri?
end

#literal?Boolean

Returns ‘true` if `self` is a literal.

Returns:

  • (Boolean)


41
42
43
# File 'lib/rdf/model/value.rb', line 41

def literal?
  false
end

#node?Boolean

Returns ‘true` if `self` is a blank node.

Returns:

  • (Boolean)


49
50
51
# File 'lib/rdf/model/value.rb', line 49

def node?
  false
end

#resource?Boolean

Returns ‘true` if `self` is a resource.

Returns:

  • (Boolean)


57
58
59
# File 'lib/rdf/model/value.rb', line 57

def resource?
  false
end

#statement?Boolean

Returns ‘true` if `self` is a statement.

Returns:

  • (Boolean)


65
66
67
# File 'lib/rdf/model/value.rb', line 65

def statement?
  false
end

#to_ntriplesString

Returns the N-Triples representation of this value.

This method is only available when the ‘rdf/ntriples’ serializer has been explicitly required.

Returns:

  • (String)

Since:

  • 0.2.1



100
101
102
# File 'lib/rdf/ntriples.rb', line 100

def to_ntriples
  RDF::NTriples.serialize(self)
end

#to_quadString

Returns the N-Triples representation of this value.

This method is only available when the ‘rdf/ntriples’ serializer has been explicitly required.

Returns:

  • (String)

Since:

  • 0.4.0



148
149
150
# File 'lib/rdf/nquads.rb', line 148

def to_quad
  RDF::NQuads.serialize(self)
end

#to_rdfRDF::Value

Returns an ‘RDF::Value` representation of `self`.

Returns:



100
101
102
# File 'lib/rdf/model/value.rb', line 100

def to_rdf
  self
end

#type_error(message) ⇒ false

Default implementation of raise_error, which returns false. Classes including RDF::TypeCheck will raise TypeError instead.

Returns:

  • (false)


129
130
131
# File 'lib/rdf/model/value.rb', line 129

def type_error(message)
  false
end

#uri?Boolean

Returns ‘true` if `self` is a URI reference.

Returns:

  • (Boolean)


83
84
85
# File 'lib/rdf/model/value.rb', line 83

def uri?
  false
end

#variable?Boolean

Returns ‘true` if `self` is a query variable.

Returns:

  • (Boolean)

Since:

  • 0.1.7



92
93
94
# File 'lib/rdf/model/value.rb', line 92

def variable?
  false
end