[ruby] refactor word-count to scan