Class: Reddy::Triple
- Inherits:
-
Object
- Object
- Reddy::Triple
- Defined in:
- lib/reddy/triple.rb
Defined Under Namespace
Classes: InvalidObject, InvalidPredicate, InvalidSubject
Instance Attribute Summary collapse
-
#object ⇒ Object
Returns the value of attribute object.
-
#predicate ⇒ Object
Returns the value of attribute predicate.
-
#subject ⇒ Object
Returns the value of attribute subject.
Instance Method Summary collapse
-
#initialize(subject, predicate, object) ⇒ Triple
constructor
Creates a new triple directly from the intended subject, predicate, and object.
- #inspect ⇒ Object
- #is_type? ⇒ Boolean
- #to_ntriples ⇒ Object
Constructor Details
#initialize(subject, predicate, object) ⇒ Triple
30 31 32 33 34 |
# File 'lib/reddy/triple.rb', line 30 def initialize (subject, predicate, object) @subject = self.class.coerce_subject(subject) @predicate = self.class.coerce_predicate(predicate) @object = self.class.coerce_object(object) end |
Instance Attribute Details
#object ⇒ Object
Returns the value of attribute object.
12 13 14 |
# File 'lib/reddy/triple.rb', line 12 def object @object end |
#predicate ⇒ Object
Returns the value of attribute predicate.
12 13 14 |
# File 'lib/reddy/triple.rb', line 12 def predicate @predicate end |
#subject ⇒ Object
Returns the value of attribute subject.
12 13 14 |
# File 'lib/reddy/triple.rb', line 12 def subject @subject end |
Instance Method Details
#inspect ⇒ Object
40 41 42 |
# File 'lib/reddy/triple.rb', line 40 def inspect [@subject, @predicate, @object].inspect end |
#is_type? ⇒ Boolean
44 45 46 |
# File 'lib/reddy/triple.rb', line 44 def is_type? @predicate.to_s == "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" end |
#to_ntriples ⇒ Object
36 37 38 |
# File 'lib/reddy/triple.rb', line 36 def to_ntriples @subject.to_ntriples + " " + @predicate.to_ntriples + " " + @object.to_ntriples + " ." end |