Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

15 lines
262 B

class String
def formatted_postcode
postcode = upcase.gsub(/\s+/, "")
case postcode.length
when 5
postcode.insert(2, " ")
when 6
postcode.insert(3, " ")
when 7
postcode.insert(4, " ")
else
self
end
end
end