How to transform data through ruby code

Hi I’m a new on Ruby
Just I’m looking for the trick or method for transform the data, this code will be part of logstash pipeline

input data:
5-7-undefined-undefined-undefined-undefined-undefined-#0(bearer successful)-5|7-5-undefined-undefined-undefined-undefined-undefined-#0(bearer successful)-7

please notice that the pipe “|” split out the blocks of data, such blocks may occur a few times

for example, considering this is my header, which will be also the name of the fields:

then I need the date

eps_bearer_id_1 = 5
bearer_qci_1 = 7
ARP_PL_1 = 2
ARP_PCI_1 = disabled
ARP_PVI_1 = enabled
bearer_casue_default_1 = #0(bearer successful)
bearer_i_1 = 5

eps_bearer_id_2 = 5
bearer_qci_2 = 7
ARP_PL_2 = 2
ARP_PCI_2 = disabled
ARP_PVI_2 = enabled
bearer_casue_default_2 = #0(bearer successful)
bearer_i_2 = 5