flags = 0 stns = [] pmax = 0 pmin = 9999 for line in ARGF case line when /WMO BLOCK NUMBER +(\d\.\d+E\+\d+)/ then ii = $1.to_f.to_i when /WMO STATION NUMBER +(\d\.\d+E\+\d+)/ then iii = $1.to_f.to_i stns.push format('%05u', ii * 1000 + iii) when /EXTENDED VERTICAL SOUNDING SIGNI +(\d\.\d+E\+\d+)/ then flag = $1.to_f.to_i flags |= flag when /PRESSURE +(\d\.\d+E\+\d+)/ then pres = $1.to_f * 0.01 pmax = pres if pres > pmax pmin = pres if pres < pmin end end puts [format('%018b', flags), pmax, pmin, stns].inspect