Class: Amigo::Triple
- Includes:
- Hamster::Immutable
- Defined in:
- lib/amigo/triple.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#predicate ⇒ Object
readonly
Returns the value of attribute predicate.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(subject, predicate, object) ⇒ Triple
constructor
A new instance of Triple.
- #inspect ⇒ Object
- #to_ntriple ⇒ Object
Constructor Details
#initialize(subject, predicate, object) ⇒ Triple
Returns a new instance of Triple.
12 13 14 15 16 |
# File 'lib/amigo/triple.rb', line 12 def initialize(subject, predicate, object) @subject = subject @predicate = predicate @object = object end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
10 11 12 |
# File 'lib/amigo/triple.rb', line 10 def object @object end |
#predicate ⇒ Object (readonly)
Returns the value of attribute predicate.
10 11 12 |
# File 'lib/amigo/triple.rb', line 10 def predicate @predicate end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
10 11 12 |
# File 'lib/amigo/triple.rb', line 10 def subject @subject end |
Instance Method Details
#<=>(other) ⇒ Object
39 40 41 |
# File 'lib/amigo/triple.rb', line 39 def <=>(other) [subject, predicate, object] <=> [other.subject, other.predicate, other.object] end |
#eql?(other) ⇒ Boolean Also known as: ==
26 27 28 29 30 31 32 |
# File 'lib/amigo/triple.rb', line 26 def eql?(other) return true if other.equal?(self) return other.class.equal?(self.class) && other.subject == self.subject && other.predicate == self.predicate && other.object == self.object end |
#hash ⇒ Object
35 36 37 |
# File 'lib/amigo/triple.rb', line 35 def hash subject.hash ^ predicate.hash ^ object.hash end |
#inspect ⇒ Object
22 23 24 |
# File 'lib/amigo/triple.rb', line 22 def inspect to_ntriple end |
#to_ntriple ⇒ Object
18 19 20 |
# File 'lib/amigo/triple.rb', line 18 def to_ntriple "#{[@subject, @predicate, @object].map(&:to_ntriple).join(" ")} ." end |