Class: RDF::Query::Result
- Inherits:
-
Object
- Object
- RDF::Query::Result
- Defined in:
- lib/rdf/query/result.rb
Overview
A set of bindings for a graph.
Instance Attribute Summary collapse
-
#bindings ⇒ Object
readonly
Returns the value of attribute bindings.
Class Method Summary collapse
Instance Method Summary collapse
-
#<<(o) ⇒ Object
Merges the Result
o
into this Result. -
#failure? ⇒ Boolean
Returns true if the executed query failed.
-
#initialize(*bindings) ⇒ Result
constructor
Creates an instance of Result with the specified bindings.
-
#success! ⇒ Object
Sets the success indicator to true.
-
#success? ⇒ Boolean
Returns true if the executed query succeeded.
- #to_s ⇒ Object
Constructor Details
#initialize(*bindings) ⇒ Result
Creates an instance of Result with the specified bindings.
14 15 16 17 |
# File 'lib/rdf/query/result.rb', line 14 def initialize(*bindings) @success = false @bindings = Set.new((bindings || []).flatten.reject{|b| b.empty?}) end |
Instance Attribute Details
#bindings ⇒ Object (readonly)
Returns the value of attribute bindings.
11 12 13 |
# File 'lib/rdf/query/result.rb', line 11 def bindings @bindings end |
Class Method Details
Instance Method Details
#<<(o) ⇒ Object
Merges the Result o
into this Result.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rdf/query/result.rb', line 35 def <<(o) raise ArgumentError, "Must be RDF::Query::Result" unless o.is_a?(Result) if o.success? if failure? success! bindings.clear end o.bindings.each do |b| bindings << b unless b.empty? end end end |
#failure? ⇒ Boolean
Returns true if the executed query failed.
20 21 22 |
# File 'lib/rdf/query/result.rb', line 20 def failure? !@success end |
#success! ⇒ Object
Sets the success indicator to true.
30 31 32 |
# File 'lib/rdf/query/result.rb', line 30 def success! @success = true end |
#success? ⇒ Boolean
Returns true if the executed query succeeded.
25 26 27 |
# File 'lib/rdf/query/result.rb', line 25 def success? @success end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/rdf/query/result.rb', line 49 def to_s "{#{bindings.collect{|b| b.to_s}.join(', ')}}" end |