Why am I getting an undefined method '**' error in my Ruby array function