#!/usr/bin/env ruby while line = STDIN.gets a = line.split d = {} a.each { |i| name, val = i.split("::") if name == "temperature" d["temperature"] = val end if name == "device_id" d["dev"] = val end } puts d.to_s end