@@ -135,7 +135,7 @@ def statement?
135135 #
136136 # @return [Boolean]
137137 def variable?
138- !( has_subject? && subject . resource? &&
138+ !( has_subject? && subject . resource? &&
139139 has_predicate? && predicate . resource? &&
140140 has_object? && ( object . resource? || object . literal? ) &&
141141 ( has_graph? ? graph_name . resource? : true ) )
@@ -150,7 +150,7 @@ def invalid?
150150 ##
151151 # @return [Boolean]
152152 def valid?
153- has_subject? && subject . resource? && subject . valid? &&
153+ has_subject? && subject . resource? && subject . valid? &&
154154 has_predicate? && predicate . uri? && predicate . valid? &&
155155 has_object? && object . term? && object . valid? &&
156156 ( has_graph? ? graph_name . resource? && graph_name . valid? : true )
@@ -228,22 +228,61 @@ def node?
228228 alias_method :has_blank_nodes? , :node?
229229
230230 ##
231+ # Checks statement equality as a quad.
232+ #
231233 # @param [Statement] other
232234 # @return [Boolean]
235+ #
236+ # @see RDF::URI#==
237+ # @see RDF::Node#==
238+ # @see RDF::Literal#==
239+ # @see RDF::Query::Variable#==
233240 def eql? ( other )
234241 other . is_a? ( Statement ) && self == other && ( self . graph_name || false ) == ( other . graph_name || false )
235242 end
236243
237244 ##
245+ # Checks statement equality as a triple.
246+ #
238247 # @param [Object] other
239248 # @return [Boolean]
249+ #
250+ # @see RDF::URI#==
251+ # @see RDF::Node#==
252+ # @see RDF::Literal#==
253+ # @see RDF::Query::Variable#==
240254 def ==( other )
241- to_a == Array ( other )
255+ to_a == Array ( other ) &&
256+ !( other . is_a? ( RDF ::Value ) && other . list? )
242257 end
243258
244259 ##
260+ # Checks statement equality with patterns.
261+ #
262+ # Uses `#eql?` to compare each of `#subject`, `#predicate`, `#object`, and
263+ # `#graph_name` to those of `other`. Any statement part which is not
264+ # present in `self` is ignored.
265+ #
266+ # @example
267+ # statement = RDF::Statement.new(RDF::URI('s'), RDF::URI('p'), RDF::URI('o'))
268+ # pattern = RDF::Statement.new(RDF::URI('s'), RDF::URI('p'), RDF::Query::Variable.new)
269+ #
270+ # # true
271+ # statement === statement
272+ # pattern === statement
273+ # RDF::Statement.new(nil, nil, nil) === statement
274+ #
275+ # # false
276+ # statement === pattern
277+ # statement === RDF::Statement.new(nil, nil, nil)
278+ #
245279 # @param [Statement] other
246280 # @return [Boolean]
281+ #
282+ # @see RDF::URI#eql?
283+ # @see RDF::Node#eql?
284+ # @see RDF::Literal#eql?
285+ # @see RDF::Query::Variable#eql?
247286 def ===( other )
248287 return false if has_object? && !object . eql? ( other . object )
249288 return false if has_predicate? && !predicate . eql? ( other . predicate )
0 commit comments