Class: Triple

Inherits:
Object
  • Object
show all
Defined in:
lib/rena/triple.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject, predicate, object) ⇒ Triple

Creates a new triple directly from the intended subject, predicate, and object.

Example

Triple.new(BNode.new, URIRef.new("http://xmlns.com/foaf/0.1/knows"), BNode.new) # => results in the creation of a new triple and returns it

Returns

Parameters:

Raises:

  • (Error)

    Checks parameter types and raises if they are incorrect.

Author:

  • Tom Morris



20
21
22
23
24
# File 'lib/rena/triple.rb', line 20

def initialize (subject, predicate, object)
  self.check_subject(subject)
  self.check_predicate(predicate)
  self.check_object(object)
end

Instance Attribute Details

#objectObject

Returns the value of attribute object.



2
3
4
# File 'lib/rena/triple.rb', line 2

def object
  @object
end

#predicateObject

Returns the value of attribute predicate.



2
3
4
# File 'lib/rena/triple.rb', line 2

def predicate
  @predicate
end

#subjectObject

Returns the value of attribute subject.



2
3
4
# File 'lib/rena/triple.rb', line 2

def subject
  @subject
end

Instance Method Details

#to_ntriplesObject



26
27
28
# File 'lib/rena/triple.rb', line 26

def to_ntriples
  @subject.to_ntriples + " " + @predicate.to_ntriples + " " + @object.to_ntriples + " ."
end