1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
# frozen_string_literal: true
module FFaker
# Inspirations:
# TERYT registry, available at: http://www.stat.gov.pl/broker/access/index.jspa
module AddressPL
extend ModuleUtils
extend self
STREET_PREFIXES = %w[al. ul.].freeze
SQUARE_PREFIXES = %w[bulwar pasaż plac skwer zaułek].freeze
# Full Polish address with country name in French (according to Universal Postal Union).
def full_address(include_country = false, include_secondary = false)
address = "#{street_address(include_secondary)} #{postal_code} #{city}"
address = "#{address} POLOGNE" if include_country
address
end
def street_address(include_secondary = false)
address = "#{street_name} #{building_number}"
address = "#{address}#{secondary_number}" if include_secondary
address
end
def street_name
fetch_sample([street, square])
end
def street
"#{street_prefix} #{fetch_sample(STREET)}"
end
def square
"#{square_prefix} #{fetch_sample(SQUARE)}"
end
# A voivodeship is an administrative area in Poland - a Polish equivalent of state.
def voivodeship
fetch_sample(VOIVODESHIP)
end
alias state voivodeship
alias province voivodeship
def voivodeship_abbr
fetch_sample(VOIVODESHIP_ABBR)
end
def voivodeship_capital_city
fetch_sample(VOIVODESHIP_CAPITAL_CITY)
end
def city
fetch_sample(CITY)
end
def building_number # :nodoc:
rand(1..199)
end
def secondary_number # :nodoc:
case rand(0..1)
when 0 then " m. #{building_number}"
when 1 then "/#{building_number}"
end
end
def zip_code
FFaker.numerify('##-###')
end
alias postal_code zip_code
def street_prefix
fetch_sample(STREET_PREFIXES)
end
def square_prefix
fetch_sample(SQUARE_PREFIXES)
end
end
end
|