Class: Pho::Update::Statement
- Inherits:
-
Object
- Object
- Pho::Update::Statement
- Defined in:
- lib/pho/changeset.rb
Overview
Base class capturing data relating to a reified RDF triple described in a Changeset
Direct Known Subclasses
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Object value.
-
#predicate ⇒ Object
readonly
URI of predicate.
-
#subject ⇒ Object
readonly
URI of subject.
Class Method Summary collapse
-
.create_literal(subject, predicate, object, lang = nil, datatype = nil) ⇒ Object
Create a Statement referring to a literal.
-
.create_resource(subject, predicate, object) ⇒ Object
Create a Statement referring to a resource.
Instance Method Summary collapse
-
#to_rdf ⇒ Object
Create an RDF/XML fragment describing this Statement.
Instance Attribute Details
#object ⇒ Object (readonly)
Object value. May be uri or literal
20 21 22 |
# File 'lib/pho/changeset.rb', line 20 def object @object end |
#predicate ⇒ Object (readonly)
URI of predicate
18 19 20 |
# File 'lib/pho/changeset.rb', line 18 def predicate @predicate end |
#subject ⇒ Object (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_rdf ⇒ Object
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 |