class Faker::Address
def zip_code(state_abbreviation: '')
-
(String)
-
Parameters:
-
state_abbreviation
(String
) -- an abbreviation for a state where the zip code should be located.
def zip_code(state_abbreviation: '') if state_abbreviation.empty? letterified_string = letterify(fetch('address.postcode')) return numerify(letterified_string, leading_zero: true) end # provide a zip code that may be valid for the state provided # note: zip code may appear in the correct format for the state provided but may not be an actual state zip. bothify(fetch("address.postcode_by_state.#{state_abbreviation}")) end