Refactor ruby narray detector