rb_cObject
An abstract base class for encapsulating various kinds of query results.
$Id$
Copyright © 2008-2009, Michael Granger All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Return a Hash of supported QueryResult formatters (the keys of which are valid) arguments to #format.
Redleaf::QueryResult.formatters # => { "xml" => { :uri => #<URI::HTTP:0x197648 URL:http://www.w3.org/2005/sparql-results#>, :label => "SPARQL Query Results Format 2007-06-14", :mimetype => "application/sparql-results+xml" }, "json" => { :uri => #<URI::HTTP:0x1973fa URL:http://www.w3.org/2001/sw/DataAccess/json-sparql/>, :label => "JSON", :mimetype => "text/json" } }
static VALUE rleaf_redleaf_queryresult_s_formatters( VALUE klass )
Virtual method — this should be overridden in all concrete subclasses.
static VALUE rleaf_redleaf_queryresult_each( VALUE self )
Return the query results as a String in the format specified by the formaturi. You can get the format URI from the Redleaf::QueryResult.formatters hash.
formaturi = Redleaf::QueryResult.formatters['json'][:uri] result.formatted_as( formaturi ) # => ...
static VALUE rleaf_redleaf_queryresult_formatted_as( VALUE self, VALUE format )
Proxy method — handle serialization format convenience calls like #to_json, #to_xml, etc.
# File lib/redleaf/queryresult.rb, line 68 68: def method_missing( sym, *args ) 69: super unless sym.to_s =~ /^to_(\w+)$/ 70: 71: format = $1 72: formatters = self.class.formatters 73: unless formatters.key?( format ) 74: raise Redleaf::FeatureError, 75: "local Redland installation does not have a '%s' formatter" 76: end 77: 78: return self.formatted_as( formatters[format][:uri] ) 79: end
Return the query result as JSON in the format specified by www.w3.org/2001/sw/DataAccess/json-sparql/.
# File lib/redleaf/queryresult.rb, line 51 51: def to_json 52: json = self.formatted_as( self.class.formatters['json'][:uri] ) 53: 54: # Work around the doubled-quotes bug 55: return json.gsub( %r{""(ordered|distinct)}, %{"\\1} ) 56: end
Return the query result as RDF/XML in the format specified by www.w3.org/2005/sparql-results.
# File lib/redleaf/queryresult.rb, line 61 61: def to_xml 62: return self.formatted_as( self.class.formatters['xml'][:uri] ) 63: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.