Defines methods to return random location data.
Returns the first line of a US maiiling address (street number, street name, street type) Example:
Random.address_line_1 = “24317 Jefferson Blvd”
# File lib/random_data/locations.rb, line 26 def address_line_1 "#{rand(40000)} #{@@streetnames.rand} #{@@street_types.rand}" end
Returns the first line of a US maiiling address (street number, street name, street type) Example:
Random.address_line_1 = “24317 Jefferson Blvd”
# File lib/random_data/locations.rb, line 40 def address_line_2 "#{@@line2types.rand} #{rand(999)}" end
Returns a generic city name, with an attempt to have some internationl appeal
Random.city = “Tekoza”
# File lib/random_data/locations.rb, line 129 def city @@cities.rand end
Returns a country name, as listed by the World Bank
Random.country = “Kenya”
# File lib/random_data/locations.rb, line 117 def country @@countries.rand end
Returns a state 2-character abbreviation Random.state_code = “IL”
# File lib/random_data/locations.rb, line 82 def state_code @@us_states.rand[1] end
Returns a full state name
Random.state_full = “Texas”
# File lib/random_data/locations.rb, line 89 def state_full @@us_states.rand[0] end
Returns a string providing something in the general form of a UK post code. Like the zip codes, this might not actually be valid. Doesn’t cover London whose codes are like “SE1”.
# File lib/random_data/locations.rb, line 55 def uk_post_code post_towns = %w(BM CB CV LE LI LS KT MK NE OX PL YO) # Can't remember any othes at the moment number_1 = rand(100).to_s number_2 = rand(100).to_s # Easier way to do this? letters = ("AA".."ZZ").to_a.rand return "#{post_towns.rand}#{number_1} #{number_2}#{letters}" end
Returns a random 5-digit string, not guaranteed to be a legitimate zip code. Legal zip codes can have leading zeroes and thus they need to be strings.
# File lib/random_data/locations.rb, line 47 def zipcode "%05d" % rand(99999) end