class RDF::Query::Pattern

Public Instance Methods

eql?(other) click to toggle source

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?}.

@param [Statement] other @return [Boolean]

@see RDF::URI#== @see RDF::Node#== @see RDF::Literal#== @see RDF::Query::Variable#==

# 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
initialize!() click to toggle source
# 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
Also aliased as: orig_initialize!
orig_initialize!()

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

Alias for: initialize!