#!/usr/bin/env ruby $devices = { "f4:01" => "outside", "1f:01" => "inside" } while line = STDIN.gets a = line.split d = {} a.each { |i| name, val = i.split("::") if name == "timestamp" d["timestamp"] = val.to_f end if name == "temperature" d["temperature"] = val.to_f end if name == "device_id" d["dev"] = devices[val] end } puts d.to_s end