-
-
Save mlandauer/5182346 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See http://en.wikipedia.org/wiki/Postcodes_in_Australia | |
# Postcodes that are used for LVRs and PO boxes only | |
def australian_postcodes_po_boxes | |
nsw = (1000..1999).to_a | |
act = (200..299).to_a | |
vic = (8000..8999).to_a | |
qld = (9000..9999).to_a | |
sa = (5800..5999).to_a | |
wa = (6800..6999).to_a | |
tas = (7800..7999).to_a | |
nt = (900..999).to_a | |
# Convert integers to strings (postcodes are *not* integers) | |
(nsw + act + vic + qld + sa + wa + tas + nt).map { |p| "%04i" % p } | |
end | |
# Postcodes that are used for regular street addresses (Not PO boxes and LVRs) | |
def australian_postcodes_regular | |
nsw = (2000..2599).to_a + | |
(2619..2898).to_a + | |
(2921..2999).to_a | |
act = (2600..2618).to_a + | |
(2900..2920).to_a | |
vic = (3000..3999).to_a | |
qld = (4000..4999).to_a | |
sa = (5000..5799).to_a | |
wa = (6000..6797).to_a | |
tas = (7000..7799).to_a | |
nt = (800..899).to_a | |
# Convert integers to strings (postcodes are *not* integers) | |
(nsw + act + vic + qld + sa + wa + tas + nt).map { |p| "%04i" % p } | |
end | |
# Returns an array of Australian Postcodes | |
def australian_postcodes | |
australian_postcodes_regular + australian_postcodes_po_boxes | |
end | |
p australian_postcodes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment