I need to parse the following input string into a hash table with the following format:
Input:
'1001=23;1001B=5;1002=0;1003=5;'
Output:
=> {'1001'=>23,'1001B'=>5,'1002'=>0,'1003'=>5}
My solution:
def parser input
output = {}
input.split(';').map {|ar| ar.split('=')}.each {|id, c| output[id]=c.to_i}
output
end
parser '1001=23;1001B=5;1002=0;1003=5;'
Any insight is appreciated.