How to remove part of name in multiple fields with Ruby in logstash?

Unfortunately this gives out below error in the logs:
[ERROR][logstash.filters.ruby ][main] Ruby exception occurred: type mismatch: String given