Class: RdfContext::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/rdf_context/resource.rb

Overview

Common super-class for things that are RDF Resources

Direct Known Subclasses

BNode, Graph, Literal, URIRef

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) parse(str)

Parse a string to a resource, in NTriples format



46
47
48
49
50
51
52
53
54
# File 'lib/rdf_context/resource.rb', line 46

def self.parse(str)
  case str
  when /^_:/    then BNode.parse(str)
  when /^</     then URIRef.parse(str)
  when /^http:/ then URIRef.parse(str)
  when /^\"/    then Literal.parse(str)
  else               Literal.parse(str)
  end
end

Instance Method Details

- (Boolean) bnode?

Returns `false`, overridden in BNode

Returns:

  • (Boolean)


33
34
35
# File 'lib/rdf_context/resource.rb', line 33

def bnode?
  false
end

- (Boolean) graph?

Returns `false`, overridden in BNode

Returns:

  • (Boolean)


41
42
43
# File 'lib/rdf_context/resource.rb', line 41

def graph?
  false
end

- (Boolean) literal?

Returns `false`, overridden in Literal

Returns:

  • (Boolean)


17
18
19
# File 'lib/rdf_context/resource.rb', line 17

def literal?
  false
end

- (Boolean) resource?

Returns `true` to indicate that this value is a resource.

Returns:

  • (Boolean)


9
10
11
# File 'lib/rdf_context/resource.rb', line 9

def resource?
  true
end

- (Boolean) uri?

Returns `false`, overridden in URIref

Returns:

  • (Boolean)


25
26
27
# File 'lib/rdf_context/resource.rb', line 25

def uri?
  false
end