Open andrew2net opened 1 year ago
@mico can you please help add this functionality? Thanks.
But ===
is an object comparator in Ruby?
Why not use something simple like pubid1.without_year == pubid2.without_year
?
But
===
is an object comparator in Ruby?
I'd say if a === b
true then b
is a member of set a
. For example (1..5) === 3
is true, but 3 === (1..5)
is false. In our case if left operand doesn't have year then it denotes a set of documents with any year.
Why not use something simple like
pubid1.without_year == pubid2.without_year
?
Because it depends on a reference. If a reference with year we need to compare with year, otherwise without year. We need something like:
class Pubid
...
def ===(other)
...
&& (self.year.nil? || self.year == other.year)
...
end
end
Ahh okay it makes sense. We just need the implementation well documented.
We use references without a year to search all years publications of a document. But reference IDs withot year doesn't match to document's PubId with year. We need a way to drop year when compare PubIds. I suggest to implement an "asymmetric" compare solution. If left operand has year then it's used, otherwise year is ignored.
It blocks https://github.com/relaton/relaton-bsi/issues/24 and https://github.com/relaton/relaton-jis/issues/2