Method: RubyUnits::Unit#=~
- Defined in:
- lib/ruby_units/unit.rb
#=~(other) ⇒ Boolean Also known as: compatible?, compatible_with?
Note:
if you want to do a regexp comparison of the unit string do this … unit.units =~ /regexp/
check to see if units are compatible, but not the scalar part this check is done by comparing signatures for performance reasons if passed a string, it will create a unit object with the string and then do the comparison
774 775 776 777 778 779 780 781 782 783 784 785 786 |
# File 'lib/ruby_units/unit.rb', line 774 def =~(other) case other when Unit signature == other.signature else begin x, y = coerce(other) return x =~ y rescue ArgumentError return false end end end |