[ruby] refactor downcasing and matcher