Class: Amigo::Store
- Includes:
- Hamster::Immutable
- Defined in:
- lib/amigo/store.rb
Instance Method Summary collapse
- #add(subject, predicate, object) ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
- #execute(query) ⇒ Object
- #hash ⇒ Object
-
#initialize ⇒ Store
constructor
A new instance of Store.
- #to_ntriples ⇒ Object
Constructor Details
#initialize ⇒ Store
Returns a new instance of Store.
15 16 17 |
# File 'lib/amigo/store.rb', line 15 def initialize @triples = Hamster.set end |
Instance Method Details
#add(subject, predicate, object) ⇒ Object
19 20 21 22 23 |
# File 'lib/amigo/store.rb', line 19 def add(subject, predicate, object) triple = Triple.new(subject, predicate, object) return self if @triples.include?(triple) transform { @triples = @triples.add(triple) } end |
#eql?(other) ⇒ Boolean Also known as: ==
33 34 35 36 37 |
# File 'lib/amigo/store.rb', line 33 def eql?(other) return true if other.equal?(self) other.class.equal?(self.class) && @triples.eql?(other.instance_variable_get(:@triples)) end |
#execute(query) ⇒ Object
25 26 27 |
# File 'lib/amigo/store.rb', line 25 def execute(query) query.execute(@triples) end |
#hash ⇒ Object
40 41 42 |
# File 'lib/amigo/store.rb', line 40 def hash @triples.hash end |
#to_ntriples ⇒ Object
29 30 31 |
# File 'lib/amigo/store.rb', line 29 def to_ntriples @triples.map(&:to_ntriple).join("\n") end |