Module: FFaker::AddressPL

Extended by:
AddressPL, ModuleUtils
Included in:
AddressPL
Defined in:
lib/ffaker/address_pl.rb

Overview

Inspirations: TERYT registry, available at: www.stat.gov.pl/broker/access/index.jspa

Constant Summary collapse

STREET_PREFIXES =
%w[al. ul.].freeze
SQUARE_PREFIXES =
%w[bulwar pasaż plac skwer zaułek].freeze

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, underscore, unique

Methods included from RandomUtils

#fetch_sample, #rand, #shuffle

Instance Method Details

#building_numberObject

:nodoc:


58
59
60
# File 'lib/ffaker/address_pl.rb', line 58

def building_number # :nodoc:
  rand(1..199)
end

#cityObject


54
55
56
# File 'lib/ffaker/address_pl.rb', line 54

def city
  fetch_sample(CITY)
end

#full_address(include_country = false, include_secondary = false) ⇒ Object

Full Polish address with country name in French (according to Universal Postal Union).


14
15
16
17
18
# File 'lib/ffaker/address_pl.rb', line 14

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

#secondary_numberObject

:nodoc:


62
63
64
65
66
67
# File 'lib/ffaker/address_pl.rb', line 62

def secondary_number # :nodoc:
  case rand(0..1)
  when 0 then " m. #{building_number}"
  when 1 then "/#{building_number}"
  end
end

#squareObject


34
35
36
# File 'lib/ffaker/address_pl.rb', line 34

def square
  "#{square_prefix} #{fetch_sample(SQUARE)}"
end

#square_prefixObject


79
80
81
# File 'lib/ffaker/address_pl.rb', line 79

def square_prefix
  fetch_sample(SQUARE_PREFIXES)
end

#streetObject


30
31
32
# File 'lib/ffaker/address_pl.rb', line 30

def street
  "#{street_prefix} #{fetch_sample(STREET)}"
end

#street_address(include_secondary = false) ⇒ Object


20
21
22
23
24
# File 'lib/ffaker/address_pl.rb', line 20

def street_address(include_secondary = false)
  address = "#{street_name} #{building_number}"
  address = "#{address}#{secondary_number}" if include_secondary
  address
end

#street_nameObject


26
27
28
# File 'lib/ffaker/address_pl.rb', line 26

def street_name
  fetch_sample([street, square])
end

#street_prefixObject


75
76
77
# File 'lib/ffaker/address_pl.rb', line 75

def street_prefix
  fetch_sample(STREET_PREFIXES)
end

#voivodeshipObject Also known as: state, province

A voivodeship is an administrative area in Poland - a Polish equivalent of state.


39
40
41
# File 'lib/ffaker/address_pl.rb', line 39

def voivodeship
  fetch_sample(VOIVODESHIP)
end

#voivodeship_abbrObject


46
47
48
# File 'lib/ffaker/address_pl.rb', line 46

def voivodeship_abbr
  fetch_sample(VOIVODESHIP_ABBR)
end

#voivodeship_capital_cityObject


50
51
52
# File 'lib/ffaker/address_pl.rb', line 50

def voivodeship_capital_city
  fetch_sample(VOIVODESHIP_CAPITAL_CITY)
end

#zip_codeObject Also known as: postal_code


69
70
71
# File 'lib/ffaker/address_pl.rb', line 69

def zip_code
  FFaker.numerify('##-###')
end