class RDF::AllegroGraph::Query::FunctorExpression
A functor expression in a Prolog query (other than an ordinary pattern).
@see RDF::Query::Pattern @see RDF::AllegroGraph::Functors
Attributes
arguments[R]
The arguments passed to this functor.
name[R]
The name of this functor.
Public Class Methods
new(name, *arguments)
click to toggle source
Construct a new functor.
@param [String] name @param [Array<Symbol,RDF::Value,value>] arguments
The arguments to the functor, which may be either variables, RDF::Value objects, or Ruby values that we can convert to literals.
# File lib/rdf/allegro_graph/query/functor_expression.rb, line 21 def initialize(name, *arguments) @name = name @arguments = arguments.map do |arg| case arg when Symbol then RDF::Query::Variable.new(arg) when PrologLiteral, RDF::Value then arg else RDF::Literal.new(arg) end end end
Public Instance Methods
to_prolog(repository)
click to toggle source
Convert this functor to a Prolog Lisp expression.
@param [RDF::AllegroGraph::Repository] repository @return [String] @private
# File lib/rdf/allegro_graph/query/functor_expression.rb, line 51 def to_prolog(repository) args = arguments.map {|a| repository.serialize_prolog(a) } "(#{name} #{args.join(" ")})" end
variables()
click to toggle source
Return a hash table of all variables used in this functor. This is intended to be duck-type compatible with the same method in RDF::Query::Pattern.
@return [Hash<Symbol,RDF::Query::Variable>] @see RDF::Query::Pattern#variables
# File lib/rdf/allegro_graph/query/functor_expression.rb, line 38 def variables result = {} @arguments.each do |arg| result.merge!(arg.variables) if arg.is_a?(RDF::Query::Variable) end result end