Class: RDF::Query::Pattern

Inherits:
Object
  • Object
show all
Defined in:
lib/rdf/n3/refinements.rb,
lib/rdf/n3/extensions.rb

Overview

Refinements on RDF::Query::Pattern

Instance Method Summary collapse

Instance Method Details

#eql?(other) ⇒ Boolean

Checks pattern equality against a statement, considering nesting an lists.

  • A pattern which has a pattern as a subject or an object, matches a statement having a statement as a subject or an object using #eql?.

Parameters:

Returns:

  • (Boolean)

See Also:

  • URI#==
  • Node#==
  • Literal#==
  • Variable#==


155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/rdf/n3/extensions.rb', line 155

def eql?(other)
  return false unless other.is_a?(RDF::Statement) && (self.graph_name || false) == (other.graph_name || false)

  [:subject, :predicate, :object].each do |part|
    case o = self.send(part)
    when RDF::Query::Pattern, RDF::List
      return false unless o.eql?(other.send(part))
    else
      return false unless o == other.send(part)
    end
  end
  true
end

#evaluate(bindings, formulae:, **options) ⇒ RDF::Statement, RDF::N3::Algebra::Formula

Evaluates the pattern using the given variable ‘bindings` by cloning the pattern replacing variables with their bindings recursively. If the resulting pattern is constant, it is cast as a statement.

Parameters:

  • bindings (Hash{Symbol => RDF::Term})

    a query solution containing zero or more variable bindings

  • options (Hash{Symbol => Object})

    ({}) options passed from query

Returns:

See Also:

  • SPARQL::Algebra::Expression.evaluate


16
# File 'lib/rdf/n3/refinements.rb', line 16

def evaluate(bindings, formulae:, **options); end

#initialize!Object



132
133
134
135
136
137
138
139
140
# File 'lib/rdf/n3/extensions.rb', line 132

def initialize!
  if @options[:ndvars]
    @graph_name = @graph_name.to_ndvar(nil) if @graph_name
    @subject = @subject.to_ndvar(@graph_name)
    @predicate = @predicate.to_ndvar(@graph_name)
    @object = @object.to_ndvar(@graph_name)
  end
  orig_initialize!
end

#orig_initialize!Object

Overrides ‘#initialize!` to turn blank nodes into non-distinguished variables, if the `:ndvars` option is set.



131
# File 'lib/rdf/n3/extensions.rb', line 131

alias_method :orig_initialize!, :initialize!

#valid?Boolean

Refines ‘#valid?` to allow literal subjects and BNode predicates.

Returns:

  • (Boolean)


5
# File 'lib/rdf/n3/refinements.rb', line 5

def valid?; end