Module: RDF::Value

Included in:
Statement, Term
Defined in:
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

- (Boolean) graph?

Returns true if self is a graph.

Returns:

  • (Boolean)


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

def graph?
  false
end

- (String) inspect

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!

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

- (Boolean) iri?

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

- (Boolean) literal?

Returns true if self is a literal.

Returns:

  • (Boolean)


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

def literal?
  false
end

- (Boolean) node?

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

- (Boolean) resource?

Returns true if self is a resource.

Returns:

  • (Boolean)


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

def resource?
  false
end

- (Boolean) statement?

Returns true if self is a statement.

Returns:

  • (Boolean)


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

def statement?
  false
end

- (String) to_ntriples

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

- (RDF::Value) to_rdf

Returns an RDF::Value representation of self.

Returns:



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

def to_rdf
  self
end

- (Boolean) uri?

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

- (Boolean) variable?

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