def parse_contact
contact ||= {}
p("whois.nic.hu: parse_contact") if 1 == 2 || $DEBUG
while @input.scan(/(.+?):\s+(.*)\n/)
key, value = @input[1].strip, @input[2].strip
if key == 'hun-id'
a1 = contact['address'][1].split(/\s/)
zip = a1.shift
city = a1.join(' ')
if @ast[value].nil?
@ast[value] = {
"id" => value,
"name" => contact['name'],
"organization" => contact['org'],
"address" => contact['address'][0],
"city" => city,
"zip" => zip,
"country_code" => contact['address'][2],
"phone" => contact['phone'],
"fax" => contact['fax-no'],
"email" => contact['e-mail']
}
else
@ast[value]["id"] ||= value
@ast[value]["name"] ||= contact['name']
@ast[value]["organization"] ||= contact['org']
@ast[value]["address"] ||= contact['address'][0]
@ast[value]["city"] ||= city
@ast[value]["zip"] ||= zip
@ast[value]["country_code"] ||= contact['address'][2]
@ast[value]["phone"] ||= contact['phone']
@ast[value]["fax"] ||= contact['fax-no']
@ast[value]["email"] ||= contact['e-mail']
end
contact = {}
elsif key == 'person'
contact['name'] = value
elsif key == 'org'
if value =~ /org_name_hun:\s+(.*)\Z/
contact['name'] = $1
elsif value =~ /org_name_eng:\s+(.*)\Z/
contact['org'] = $1
else
contact['org'] = value
end
elsif key == 'address' && !contact['address'].nil?
contact['address'] = [contact['address'], value].flatten
else
contact[key] = value
end
end
true
end