Class: Amigo::Select
- Includes:
- Hamster::Immutable
- Defined in:
- lib/amigo/select.rb
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
- #execute(triples) ⇒ Object
- #from(store) ⇒ Object
- #hash ⇒ Object
-
#initialize(first_variable, *other_variables) ⇒ Select
constructor
A new instance of Select.
- #to_sparql ⇒ Object
- #where(subject, predicate, object) ⇒ Object
Constructor Details
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
41 42 43 44 45 46 |
# File 'lib/amigo/select.rb', line 41 def eql?(other) return true if other.equal?(self) other.class.equal?(self.class) && @variables.eql?(other.instance_variable_get(:@variables)) && @where_clauses.eql?(other.instance_variable_get(:@where_clauses)) end |
#execute(triples) ⇒ Object
31 32 33 34 35 |
# File 'lib/amigo/select.rb', line 31 def execute(triples) @where_clauses. reduce(InitialResult.new(@variables, triples), &:add). solutions end |
#from(store) ⇒ Object
27 28 29 |
# File 'lib/amigo/select.rb', line 27 def from(store) store.execute(self) end |
#hash ⇒ Object
49 50 51 |
# File 'lib/amigo/select.rb', line 49 def hash @variables.hash ^ @where_clauses.hash end |
#to_sparql ⇒ Object
37 38 39 |
# File 'lib/amigo/select.rb', line 37 def to_sparql "SELECT #{@variables.to_sparql} WHERE {#{@where_clauses.reverse.map(&:to_sparql).join(" ")}}" end |