Class: Forgery::Address
- Defined in:
- lib/forgery/forgery/address.rb
Overview
Generates random address information.
Constant Summary
Constants inherited from Forgery
Class Method Summary collapse
-
.city ⇒ Object
Gets a random city out of the ‘cities’ dictionary.
-
.continent ⇒ Object
Gets a random continent out of the ‘continents’ dictionary.
-
.country ⇒ Object
Gets a random country out of the ‘countries’ dictionary.
-
.phone ⇒ Object
Gets one of the formats from ‘phone_formats’ and converts it to numbers.
-
.province ⇒ Object
Gets a random Canadian province or territory out of the ‘provinces’ dictionary.
-
.province_abbrev ⇒ Object
Gets a random Canadian province or territory abbreviation out of the ‘province_abbrev’ dictionary.
-
.state ⇒ Object
Gets a random state out of the ‘states’ dictionary.
-
.state_abbrev ⇒ Object
Gets a random state abbreviation out of the ‘state_abbrev’ dictionary.
-
.street_address ⇒ Object
Gets a full street address, including street number, street name, and street suffix.
-
.street_name ⇒ Object
Gets a random street name out of the ‘streets’ dictionary.
-
.street_number ⇒ Object
Gets one of the formats from ‘street_number_formats’ and converts it to numbers.
-
.street_suffix ⇒ Object
Gets a random street suffix out of the ‘street_suffixes’ dictionary.
-
.zip ⇒ Object
Gets one of the formats from ‘zip_formats’ and converts it to numbers.
Methods inherited from Forgery
Extend, dictionaries, formats, load_from!, load_paths, rails?, rails_root
Class Method Details
.city ⇒ Object
Gets a random city out of the ‘cities’ dictionary.
Forgery(:address).city
# => "Anaheim"
Forgery(:address).city
# => "Sacramento"
57 58 59 |
# File 'lib/forgery/forgery/address.rb', line 57 def self.city dictionaries[:cities].random.unextend end |
.continent ⇒ Object
Gets a random continent out of the ‘continents’ dictionary.
Forgery(:address).continent
# => "Africa"
Forgery(:address).continent
# => "Europe"
146 147 148 |
# File 'lib/forgery/forgery/address.rb', line 146 def self.continent dictionaries[:continents].random.unextend end |
.country ⇒ Object
Gets a random country out of the ‘countries’ dictionary.
Forgery(:address).country
# => "Uruguay"
Forgery(:address).country
# => "Romania"
134 135 136 |
# File 'lib/forgery/forgery/address.rb', line 134 def self.country dictionaries[:countries].random.unextend end |
.phone ⇒ Object
Gets one of the formats from ‘phone_formats’ and converts it to numbers.
Forgery(:address).phone
# => "1-(416)185-8799"
Forgery(:address).phone
# => "1-(589)248-0418"
123 124 125 |
# File 'lib/forgery/forgery/address.rb', line 123 def self.phone formats[:phone].random.to_numbers end |
.province ⇒ Object
Gets a random Canadian province or territory out of the ‘provinces’ dictionary.
Forgery(:address).province
# => "Ontario"
Forgery(:address).province
# => "Northwest Territories"
90 91 92 |
# File 'lib/forgery/forgery/address.rb', line 90 def self.province dictionaries[:provinces].random.unextend end |
.province_abbrev ⇒ Object
Gets a random Canadian province or territory abbreviation out of the ‘province_abbrev’ dictionary.
Forgery(:address).province_abbrev
# => "ON"
Forgery(:address).province_abbrev
# => "NT"
101 102 103 |
# File 'lib/forgery/forgery/address.rb', line 101 def self.province_abbrev dictionaries[:province_abbrevs].random.unextend end |
.state ⇒ Object
Gets a random state out of the ‘states’ dictionary.
Forgery(:address).state
# => "Mississippi"
Forgery(:address).state
# => "Minnesota"
68 69 70 |
# File 'lib/forgery/forgery/address.rb', line 68 def self.state dictionaries[:states].random.unextend end |
.state_abbrev ⇒ Object
Gets a random state abbreviation out of the ‘state_abbrev’ dictionary.
Forgery(:address).state_abbrev
# => "GA"
Forgery(:address).state_abbrev
# => "TX"
79 80 81 |
# File 'lib/forgery/forgery/address.rb', line 79 def self.state_abbrev dictionaries[:state_abbrevs].random.unextend end |
.street_address ⇒ Object
Gets a full street address, including street number, street name, and street suffix.
Forgery(:address).street_address
# => "92 West Circle"
Forgery(:address).street_address
# => "93265 Harper Lane"
46 47 48 |
# File 'lib/forgery/forgery/address.rb', line 46 def self.street_address "#{street_number} #{street_name} #{street_suffix}" end |
.street_name ⇒ Object
Gets a random street name out of the ‘streets’ dictionary.
Forgery(:address).street_name
# => "Atwood"
Forgery(:address).street_name
# => "Fordem"
11 12 13 |
# File 'lib/forgery/forgery/address.rb', line 11 def self.street_name dictionaries[:streets].random.unextend end |
.street_number ⇒ Object
Gets one of the formats from ‘street_number_formats’ and converts it to numbers.
Forgery(:address).street_number
# => 1
Forgery(:address).street_number
# => 1234
23 24 25 |
# File 'lib/forgery/forgery/address.rb', line 23 def self.street_number formats[:street_number].random.to_numbers end |
.street_suffix ⇒ Object
Gets a random street suffix out of the ‘street_suffixes’ dictionary.
Forgery(:address).street_suffix
# => "Street"
Forgery(:address).street_suffix
# => "Parkway"
34 35 36 |
# File 'lib/forgery/forgery/address.rb', line 34 def self.street_suffix dictionaries[:street_suffixes].random.unextend end |
.zip ⇒ Object
Gets one of the formats from ‘zip_formats’ and converts it to numbers.
Forgery(:address).zip
# => "52474"
Forgery(:address).zip
# => "66702-4349"
112 113 114 |
# File 'lib/forgery/forgery/address.rb', line 112 def self.zip formats[:zip].random.to_numbers end |