Module: Faker::Address

Extended by:
Address, ModuleUtils
Included in:
Address, AddressAU, AddressBR, AddressCA, AddressDA, AddressDE, AddressFR, AddressMX, AddressSE, AddressSN, AddressUK, AddressUS
Defined in:
lib/ffaker/address.rb

Constant Summary

COMPASS_DIRECTIONS =
k %w(North East West South)
CITY_PREFIXES =
k(COMPASS_DIRECTIONS + %w(New Lake Port))
SEC_ADDR =
k ['Apt. ###', 'Suite ###']

Instance Method Summary (collapse)

Methods included from ModuleUtils

const_missing, k, underscore

Instance Method Details

- (Object) building_number



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

def building_number
  Faker.numerify(( '#' * rand(3) ) << '###')
end

- (Object) city



33
34
35
36
37
38
39
40
# File 'lib/ffaker/address.rb', line 33

def city
  case rand(4)
  when 0 then '%s %s%s' % [city_prefix, Name.first_name, city_suffix]
  when 1 then '%s %s'   % [city_prefix, Name.first_name]
  when 2 then '%s%s'    % [Name.first_name, city_suffix]
  when 3 then '%s%s'    % [Name.last_name, city_suffix]
  end
end

- (Object) city_prefix

end US deprecation



25
26
27
# File 'lib/ffaker/address.rb', line 25

def city_prefix
  CITY_PREFIXES.rand
end

- (Object) city_suffix



29
30
31
# File 'lib/ffaker/address.rb', line 29

def city_suffix
  CITY_SUFFIXES.rand
end

- (Object) country(given_code = nil)



89
90
91
92
93
94
95
96
# File 'lib/ffaker/address.rb', line 89

def country(given_code = nil)
  country_index = COUNTRY_CODE.index(given_code)
  if given_code && country_index
    COUNTRY[country_index]
  else
    COUNTRY.rand
  end
end

- (Object) country_code(given_country = nil)



98
99
100
101
102
103
104
105
# File 'lib/ffaker/address.rb', line 98

def country_code(given_country = nil)
  code_index = COUNTRY.index(given_country)
  if given_country && code_index
    COUNTRY_CODE[code_index]
  else
    COUNTRY_CODE.rand
  end
end

- (Object) neighborhood

end UK deprecation



85
86
87
# File 'lib/ffaker/address.rb', line 85

def neighborhood
  NEIGHBORHOOD.rand
end

- (Object) secondary_address



63
64
65
# File 'lib/ffaker/address.rb', line 63

def secondary_address
  Faker.numerify(SEC_ADDR.rand)
end

- (Object) street_address(include_secondary = false)



57
58
59
60
61
# File 'lib/ffaker/address.rb', line 57

def street_address(include_secondary = false)
  str = "#{building_number} #{street_name}"
  str << " #{secondary_address}" if include_secondary
  str
end

- (Object) street_name



50
51
52
53
54
55
# File 'lib/ffaker/address.rb', line 50

def street_name
  case rand(2)
  when 0 then "#{Name.last_name} #{street_suffix}"
  when 1 then "#{Name.first_name} #{street_suffix}"
  end
end

- (Object) street_suffix



42
43
44
# File 'lib/ffaker/address.rb', line 42

def street_suffix
  STREET_SUFFIX.rand
end

- (Object) uk_country



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

def uk_country
  warn '[uk_country] is deprecated. For UK addresses please use the AddressUK module'
  Faker::AddressUK.country
end

- (Object) uk_county

Deprecated.

UK specific address info. Moved into Faker::AddressUK

UK Variants



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

def uk_county
  warn '[uk_county] is deprecated. For UK addresses please use the AddressUK module'
  Faker::AddressUK.county
end

- (Object) uk_postcode



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

def uk_postcode
  warn '[uk_postcode] is deprecated. For UK addresses please use the AddressUK module'
  Faker::AddressUK.postcode
end

- (Object) us_state



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

def us_state
  warn '[us_state] is deprecated. For US addresses please use the AddressUS module'
  Faker::AddressUS.state
end

- (Object) us_state_abbr



19
20
21
22
# File 'lib/ffaker/address.rb', line 19

def us_state_abbr
  warn '[state_abbr] is deprecated. For US addresses please use the AddressUS module'
  Faker::AddressUS.state_abbr
end

- (Object) zip_code

Deprecated.

US specific address info. Moved into Faker::AddressUS



9
10
11
12
# File 'lib/ffaker/address.rb', line 9

def zip_code
  warn '[zip_code] is deprecated. For US addresses please use the AddressUS module'
  Faker::AddressUS.zip_code
end