class Faker::Address

def building_number

Returns:
  • (String) -
def building_number
  bothify(fetch('address.building_number'))
end

def city(options: {})

Returns:
  • (String) -

Options Hash: (**with_state)
  • Whether (Boolean) -- to include the state name in the output.

Parameters:
  • options (Hash) --
def city(options: {})
  parse(options[:with_state] ? 'address.city_with_state' : 'address.city')
end

def city_prefix

Returns:
  • (String) -
def city_prefix
  fetch('address.city_prefix')
end

def city_suffix

Returns:
  • (String) -
def city_suffix
  fetch('address.city_suffix')
end

def community

Returns:
  • (String) -
def community
  parse('address.community')
end

def country

Returns:
  • (String) -
def country
  fetch('address.country')
end

def country_by_code(code: 'US')

Returns:
  • (String) -

Parameters:
  • code (String) -- An ISO country code.
def country_by_code(code: 'US')
  fetch("address.country_by_code.#{code}")
end

def country_code

Returns:
  • (String) -
def country_code
  fetch('address.country_code')
end

def country_code_long

Returns:
  • (String) -
def country_code_long
  fetch('address.country_code_long')
end

def country_name_to_code(name: 'united_states')

Returns:
  • (String) -

Parameters:
  • name (String) -- Country name in snake_case format.
def country_name_to_code(name: 'united_states')
  fetch("address.country_by_name.#{name}")
end

def full_address

Returns:
  • (String) -
def full_address
  parse('address.full_address')
end

def full_address_as_hash(*attrs, **attrs_params)

Returns:
  • (Hash) -
def full_address_as_hash(*attrs, **attrs_params)
  attrs.map!(&:to_sym)
  attrs_params.transform_keys!(&:to_sym)
  attrs.map do |attr|
    { "#{attr}": attrs_params[attr] ? send(attr, **attrs_params[attr]) : send(attr) }
  end.reduce({}, :merge)
end

def latitude

Returns:
  • (Float) -
def latitude
  ((rand * 180) - 90).to_f
end

def longitude

Returns:
  • (Float) -
def longitude
  ((rand * 360) - 180).to_f
end

def mail_box

Returns:
  • (String) -
def mail_box
  bothify(fetch('address.mail_box'))
end

def secondary_address

Returns:
  • (String) -
def secondary_address
  bothify(fetch('address.secondary_address'))
end

def state

Returns:
  • (String) -
def state
  fetch('address.state')
end

def state_abbr

Returns:
  • (String) -
def state_abbr
  fetch('address.state_abbr')
end

def street_address(include_secondary: false)

Returns:
  • (String) -

Parameters:
  • include_secondary (Boolean) -- Whether or not to include the secondary address.
def street_address(include_secondary: false)
  numerify(parse('address.street_address') + (include_secondary ? " #{secondary_address}" : ''))
end

def street_name

Returns:
  • (String) -
def street_name
  parse('address.street_name')
end

def street_suffix

Returns:
  • (String) -
def street_suffix
  fetch('address.street_suffix')
end

def time_zone

Returns:
  • (String) -
def time_zone
  fetch('address.time_zone')
end

def zip_code(state_abbreviation: '')

Returns:
  • (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