I am not familiar with ruby, but as my data looks quite recursive I found sample code for recursive "split" at http://billpatrianakos.me/blog/2015/05/31/turn-a-string-into-a-hash-with-string-dot-to-hash-in-ruby/
line1 = 'EUR:500:1,EUR:1000:2,EUR:2000:3,EUR:5000:4,EUR:10000:5,EUR:20000:6,EUR:50000:7'
class String
def to_hash(arr_sep=',', key_sep=':')
array = self.split(arr_sep)
currency = {}
denomination = {}
array.each do |e|
key_value = e.split(key_sep)
denomination[key_value[1]] = key_value[2]
currency[key_value[0]] = denomination
end
return currency
end
end
line1.to_hash
produces
=> {"EUR"=>{"500"=>"1", "1000"=>"2", "2000"=>"3", "5000"=>"4", "10000"=>"5", "20000"=>"6", "50000"=>"7"}}
Obviously that is a bit heavy to put it into each filters per message, and the 'denomination' array should maybe just become a tag or field.
But before I am tempted to write a filter plugin I'd still like to hear other opinions.