Class: RdfaParser::Triple
- Inherits:
-
Object
- Object
- RdfaParser::Triple
- Defined in:
- lib/rdfa_parser/triple.rb
Overview
Triple from Reddy, to aid it merger
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
- #eql?(other) ⇒ Boolean (also: #==)
-
#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
- #to_s ⇒ Object
Constructor Details
#initialize(subject, predicate, object) ⇒ Triple
22 23 24 25 26 |
# File 'lib/rdfa_parser/triple.rb', line 22 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.
4 5 6 |
# File 'lib/rdfa_parser/triple.rb', line 4 def object @object end |
#predicate ⇒ Object
Returns the value of attribute predicate.
4 5 6 |
# File 'lib/rdfa_parser/triple.rb', line 4 def predicate @predicate end |
#subject ⇒ Object
Returns the value of attribute subject.
4 5 6 |
# File 'lib/rdfa_parser/triple.rb', line 4 def subject @subject end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
42 43 44 45 46 47 |
# File 'lib/rdfa_parser/triple.rb', line 42 def eql? (other) other.is_a?(self.class) && other.subject == self.subject && other.predicate == self.predicate && other.object == self.object end |
#inspect ⇒ Object
34 35 36 |
# File 'lib/rdfa_parser/triple.rb', line 34 def inspect [@subject, @predicate, @object].inspect end |
#is_type? ⇒ Boolean
38 39 40 |
# File 'lib/rdfa_parser/triple.rb', line 38 def is_type? @predicate.to_s == "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" end |
#to_ntriples ⇒ Object
28 29 30 |
# File 'lib/rdfa_parser/triple.rb', line 28 def to_ntriples @subject.to_ntriples + " " + @predicate.to_ntriples + " " + @object.to_ntriples + " ." end |
#to_s ⇒ Object
32 |
# File 'lib/rdfa_parser/triple.rb', line 32 def to_s; self.to_ntriples; end |