Alternatively, you can use the triple equals ( === ) operator for the Regexp class, which is used to determine equality when using case syntax.
@calc.lda = /DC-000044-10|DC-67-09/ === @calc.docket_num @calc.lda => true
Beware
/Regexp/ === String completely different from String === /Regexp/ !!!! The method is not commutative. Each class implements === differently. For this question, the regex should be to the left of === .
To implement Regexp, you can see additional documentation on this subject (starting with Ruby 2.2.1) here .
Curley
source share