responsible for constructing a query, and returning the io stream for the query, and creating a Result has a session object, input, and options
Methods
public class
public instance
Included modules
- OpenURI
Attributes
input | [RW] | |
options | [RW] | |
session | [RW] |
Public class methods
# File lib/wac/query.rb, line 11 def initialize(input, options = {}) @input = input @session = options.delete(:session) @options = options end
Public instance methods
go and fetch the result, this is done automaticaly if you ask for the result
# File lib/wac/query.rb, line 23 def fetch @result = Result.new(data, :query => self) end
has the result been fetched?
# File lib/wac/query.rb, line 18 def fetched? @result ? true : false end
# File lib/wac/query.rb, line 53 def inspect out = "q: \"#{input}\"" out << " #{options[:podstate]}" if options[:podstate] out << " (assuming #{options[:assumption]})" if options[:assumption] out << ", a: #{result.datatypes}" if fetched? out end
the full set of options used to make this query, including those inherited form the session
# File lib/wac/query.rb, line 39 def query_options opts = options.merge(:input => input) session ? session.query_options.merge(opts) : opts end
use session query_uri, or Wac.query_uri if no session available
# File lib/wac/query.rb, line 49 def query_uri session ? session.query_uri : Wac.query_uri end
the query result
# File lib/wac/query.rb, line 28 def result fetch unless fetched? @result end
the uri that this query will issue a get request to
# File lib/wac/query.rb, line 34 def uri "#{query_uri}?#{query_options.to_query}" end