Class: Faker::Address

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/address.rb

Constant Summary

Constants inherited from Base

Base::Letters, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, sample, shuffle, translate, unique, with_locale

Class Method Details

.building_numberObject



22
23
24
# File 'lib/faker/address.rb', line 22

def building_number
  bothify(fetch('address.building_number'))
end

.city(options = {}) ⇒ Object



6
7
8
# File 'lib/faker/address.rb', line 6

def city(options = {})
  parse(options[:with_state] ? 'address.city_with_state' : 'address.city')
end

.city_prefixObject



47
# File 'lib/faker/address.rb', line 47

def city_prefix;        fetch('address.city_prefix');       end

.city_suffixObject



46
# File 'lib/faker/address.rb', line 46

def city_suffix;        fetch('address.city_suffix');       end

.communityObject



26
27
28
# File 'lib/faker/address.rb', line 26

def community
  parse('address.community')
end

.countryObject



50
# File 'lib/faker/address.rb', line 50

def country;            fetch('address.country');           end

.country_codeObject



51
# File 'lib/faker/address.rb', line 51

def country_code;       fetch('address.country_code');      end

.country_code_longObject



52
# File 'lib/faker/address.rb', line 52

def country_code_long;  fetch('address.country_code_long'); end

.full_addressObject



62
63
64
# File 'lib/faker/address.rb', line 62

def full_address
  parse('address.full_address')
end

.latitudeObject



54
55
56
# File 'lib/faker/address.rb', line 54

def latitude
  ((rand * 180) - 90).to_s
end

.longitudeObject



58
59
60
# File 'lib/faker/address.rb', line 58

def longitude
  ((rand * 360) - 180).to_s
end

.secondary_addressObject



18
19
20
# File 'lib/faker/address.rb', line 18

def secondary_address
  bothify(fetch('address.secondary_address'))
end

.stateObject



49
# File 'lib/faker/address.rb', line 49

def state;              fetch('address.state');             end

.state_abbrObject



48
# File 'lib/faker/address.rb', line 48

def state_abbr;         fetch('address.state_abbr');        end

.street_address(include_secondary = false) ⇒ Object



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

def street_address(include_secondary = false)
  numerify(parse('address.street_address') + (include_secondary ? ' ' + secondary_address : ''))
end

.street_nameObject



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

def street_name
  parse('address.street_name')
end

.street_suffixObject



45
# File 'lib/faker/address.rb', line 45

def street_suffix;      fetch('address.street_suffix');     end

.time_zoneObject



38
39
40
# File 'lib/faker/address.rb', line 38

def time_zone
  fetch('address.time_zone')
end

.zip_code(state_abbreviation = '') ⇒ Object Also known as: zip, postcode



30
31
32
33
34
35
36
# File 'lib/faker/address.rb', line 30

def zip_code(state_abbreviation = '')
  return bothify(fetch('address.postcode')) if state_abbreviation === ''

  # provide a zip code that is valid for the state provided
  # see http://www.fincen.gov/forms/files/us_state_territory_zip_codes.pdf
  bothify(fetch('address.postcode_by_state.' + state_abbreviation))
end