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

.parse(str) ⇒ Object

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

#bnode?Boolean

Returns `false`, overridden in BNode

Returns:

  • (Boolean)


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

def bnode?
  false
end

#graph?Boolean

Returns `false`, overridden in BNode

Returns:

  • (Boolean)


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

def graph?
  false
end

#literal?Boolean

Returns `false`, overridden in Literal

Returns:

  • (Boolean)


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

def literal?
  false
end

#resource?Boolean

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

#uri?Boolean

Returns `false`, overridden in URIref

Returns:

  • (Boolean)


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

def uri?
  false
end