Module: FFaker::AddressPL

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

Overview

Author Walerian Sobczak <[email protected]> github.com/walerian777 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:


60
61
62
# File 'lib/ffaker/address_pl.rb', line 60

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

#cityObject


56
57
58
# File 'lib/ffaker/address_pl.rb', line 56

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).


16
17
18
19
20
# File 'lib/ffaker/address_pl.rb', line 16

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:


64
65
66
67
68
69
# File 'lib/ffaker/address_pl.rb', line 64

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

#squareObject


36
37
38
# File 'lib/ffaker/address_pl.rb', line 36

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

#square_prefixObject


81
82
83
# File 'lib/ffaker/address_pl.rb', line 81

def square_prefix
  fetch_sample(SQUARE_PREFIXES)
end

#streetObject


32
33
34
# File 'lib/ffaker/address_pl.rb', line 32

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

#street_address(include_secondary = false) ⇒ Object


22
23
24
25
26
# File 'lib/ffaker/address_pl.rb', line 22

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

#street_nameObject


28
29
30
# File 'lib/ffaker/address_pl.rb', line 28

def street_name
  fetch_sample([street, square])
end

#street_prefixObject


77
78
79
# File 'lib/ffaker/address_pl.rb', line 77

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.


41
42
43
# File 'lib/ffaker/address_pl.rb', line 41

def voivodeship
  fetch_sample(VOIVODESHIP)
end

#voivodeship_abbrObject


48
49
50
# File 'lib/ffaker/address_pl.rb', line 48

def voivodeship_abbr
  fetch_sample(VOIVODESHIP_ABBR)
end

#voivodeship_capital_cityObject


52
53
54
# File 'lib/ffaker/address_pl.rb', line 52

def voivodeship_capital_city
  fetch_sample(VOIVODESHIP_CAPITAL_CITY)
end

#zip_codeObject Also known as: postal_code


71
72
73
# File 'lib/ffaker/address_pl.rb', line 71

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