Method: RDF::Query::Pattern#variable_count
- Defined in:
- lib/rdf/query/pattern.rb
#variable_count ⇒ Integer Also known as: cardinality, arity
Returns the number of variables in this pattern.
Note: this does not count distinct variables, and will therefore e.g. return 3 even if two terms are actually the same variable.
272 273 274 275 276 277 |
# File 'lib/rdf/query/pattern.rb', line 272 def variable_count [subject, predicate, object, graph_name].inject(0) do |memo, term| memo += (term.is_a?(Variable) ? 1 : (term.respond_to?(:variable_count) ? term.variable_count : 0)) end end |