Class: Pho::Update::Statement

Inherits:
Object
  • Object
show all
Defined in:
lib/pho/changeset.rb

Overview

Base class capturing data relating to a reified RDF triple described in a Changeset

Direct Known Subclasses

LiteralStatement, ResourceStatement

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#objectObject (readonly)

Object value. May be uri or literal



20
21
22
# File 'lib/pho/changeset.rb', line 20

def object
  @object
end

#predicateObject (readonly)

URI of predicate



18
19
20
# File 'lib/pho/changeset.rb', line 18

def predicate
  @predicate
end

#subjectObject (readonly)

URI of subject



16
17
18
# File 'lib/pho/changeset.rb', line 16

def subject
  @subject
end

Class Method Details

.create_literal(subject, predicate, object, lang = nil, datatype = nil) ⇒ Object

Create a Statement referring to a literal. Can have one of lang or datatype but not both

subject:: URI of subject of triple
predicate:: URI of predicate of triple
object:: literal value
lang:: language for literal
datatype:: datatype for literal


29
30
31
# File 'lib/pho/changeset.rb', line 29

def Statement.create_literal(subject, predicate, object, lang=nil, datatype=nil)
  return LiteralStatement.new(subject, predicate, object, lang, datatype)
end

.create_resource(subject, predicate, object) ⇒ Object

Create a Statement referring to a resource

subject:: URI of subject of triple
predicate:: URI of predicate of triple
object:: resource uri


38
39
40
# File 'lib/pho/changeset.rb', line 38

def Statement.create_resource(subject, predicate, object)
    return ResourceStatement.new(subject, predicate, object)
end

Instance Method Details

#to_rdfObject

Create an RDF/XML fragment describing this Statement



43
44
45
46
47
48
49
50
# File 'lib/pho/changeset.rb', line 43

def to_rdf()
  rdf = "<rdf:Statement>"
  rdf << write_subject()
  rdf << "  <rdf:predicate rdf:resource=\"#{@predicate}\"/>"
  rdf << write_object()
  rdf << "</rdf:Statement>"
  return rdf          
end